What tools are available for calculating code coverage using browser automation tests - code-coverage

I have a website written in ASP.NET MVC 3. I have put together some browser automation tests that target this website. I want to use this same set of tests to calculate the code coverage of the website code.
I know that NCover does this kind of work but based on my knowledge there are two issues. One, NCover gives code coverage figures for both framework's code and my code. Two, it's costly.

NCover has filters that you can use to ignore the framework code.
You could also use OpenCover or PartCover to get these metrics and they are both open source and free - they also have filters.
Hooking them into IIS is tricky but if it is for automation tests then you can run your tests against IIS express - much easier.

Related

How to do ASP.NET MVC Integration testing using selenium

I need to know is it possible to perform integration testing using selenium for ASP.NET MVC applications. If yes then What are the requirements and how to do it. Will it be an external application to test from UI or should I be using views. Really confused. Please guide
If you are planning to write the Selenium tests using C#, which I'd recommend over using any kind of test recorder, then this will be a separate project.
You will run this and it will test a deployed version of your application, ideally in a dedicated test environment. There is extensive documentation available.
Personally I and others prefer WatiN for testing web applications using C# written tests.
Selenium can be used for testing any web applications include ASP.NET MVC. In general, you add test project to solution and write tests in it. Selenium open browser and execute commands that is described in your test. You can write test in c# or can use recorder and save record as c# test.

VS 2010 and Nunit testing framework setup

I am working on an Asp.net mvc3 project (.NET 4). And required to integrate a testing tool. I tried to setup up the Nunit testing framework in my solution but it seems that there is a problem setting it up in vs2010.
now I want to know if Nunit still works in vs2010 or
Arent there a clear testing tools for vs2010.?
tnx!
Yes, VS works only with MSTest framework. But you can use some external test-runner:
TestDriven.Net
CodeRush
ReSharper
Another option - go to NUnit GUI settings and turn on test re-running when test assembly changes. Actually I like big green bar, so I have NUnit GUI opened on separate monitor. When test assembly re-builded, all latest tests executed automatically. If I want to debug some test, I use CodeRush - match better than attaching debugger to NUnit.
NUnit has a separate test runner program. I believe the workflow with NUnit is that you code the tests in VS, but you have to run them using the separate NUnit test running program. MSTest is the only unit test framework I know of that lets you run tests from directly within VS.
However, there is a VS plugin called ReSharper. Installing that gives you an NUnit test runner within VS.
Update
Also anyone can correct me if I'm wrong here, but I believe you only get the MSTest runner with versions of VS Professional and up. I don't think VS Express comes with a built-in MsTest runner.
There's Visual Nunit that'll let you run tests from within visual studio.
There's also NCrunch, still in beta but pretty cool. From their website:
NCrunch is an automated parallel continuous testing tool for Visual Studio .NET. It intelligently takes responsibility for running automated tests so that you don't have to, and it gives you a huge amount of useful information about your tests (such as code coverage and performance metrics) inline in your IDE while you work.

vs2003: quick snippet tool

I am working on a HUGE vs2003 website. Is there a quick snippet tool that i could use to connect to my dev database and test out different pieces of my code instead of running website over and over again??
Well, just because you're building a web site doesn't mean that all your code has to be in a web site project. You can create a class library which your web site depends on, and then maybe a console app to make calls to that class library for test purposes.
Ideally, however, you'd have unit tests instead of ad hoc testing. You could create those unit tests with NUnit or various other test frameworks. (Using .NET 1.1 will limit which versions of those test frameworks you can use, admittedly.)

ASP.NET MVC Unit Test

I'd like to try unit test in ASP.NET MVC framework. But I don't know which unit test framework I have to choose.
NUnit, xUnit.net, MbUnit. or the unit test framework included with Visual Studio, which one is better?
If you are interested in following BDD guidelines, I highly recommend xUnit.NET with Moq as the mocking framework. The two are some of the most forward looking and modern unit testing frameworks available these days, and combined they make both a powerful and flexible unit testing platform. xUnit.NET is extremely extensible as its Fact and Trait attributes can be extended with your own attributes, and the testing frameworks behavior can be changed to suit your needs.
A great example of this flexibility is the ObservationAttribute and supporting framework to allow BDD style testing with xunit.net, found here:
http://iridescence.no/post/Extending-xUnit-with-a-Custom-ObservationAttribute-for-BDD-Style-Testing.aspx
I use the above BDD-style testing to create Test-Class-Per-Unit style BDD tests for my ASP.NET MVC controllers (well, and everything else I unit test, too.)
ASP.Net MVC doesn't make any specific demands of a framework, any will work just fine. NUnit is the most widely used, and for that reason it is my default choice.
Once you get into unit testing, some of the other frameworks offer different advanced features that you may like to check out.
I don't know anyone using the MS unit testing framework.
I would recommend to start from xUnit if your have not used any testing framework before. It's hard to decide which framework is better but I think that xUnit is the "most modern" among NUnit, MbUnit and MSTest. Start learning xUnit from this article and then this
I am using MSTest :) so now you know one ;)
Seriously, I think that MSTest is a the best framework for the start with TDD.
It is liteweight and it is generating all that you need for the wrapup and the most important thing, it is integrated in the visual studio...so, why don't you start with mstest and later on you can switch to advanced frameworks with no problems.
So in short, I would recomend a MSTest.
cheers

Functional test software/framework that covers Asp.Net Web Apps?

I recently began to use the NexusLight, a functional test automation framework.
Are there more frameworks that does a similar job?
Related question: End-to-End application testing from a users standpoint
I haven't really looked into NexusLight but I think InCisif.net is supposed to provide a functional test framework as well. You could look into it.
I test asp.net web apps for years and the only tool I use is Watir.
VSTT 2010 should be a good bet if you are looking for functional test automation. Web Services Testing, UI testing, Biztalk testing and Data Driven Testing Support. Please look at VSTT - http://msdn.microsoft.com/en-us/library/ee338734(v=vs.90).aspx
You can also try VSTT - http://blogs.msdn.com/b/slumley/archive/2009/05/28/vsts-2010-feature-enhancements-for-web-test-playback-ui.aspx
Telerik Test Tools - http://www.telerik.com/automated-testing-tools.aspx
Visual Studio UI Test Extensibility–Scenarios & Guiding Principles - http://blogs.msdn.com/b/mathew_aniyan/archive/2011/03/28/visual-studio-ui-test-extensibility-scenarios-amp-guiding-principles.aspx
VSTS Web Test Step-by-Step Primer - http://blogs.msdn.com/b/jimmymay/archive/2009/02/23/vsts-web-test-step-by-step-primer-7-minute-video-by-microsoft-a-c-e-performance-engineer-chris-lundquist-with-copious-notes-screen-shots-from-your-humble-correspondent.aspx
Found this one too:
http://www.automatedqa.com/products/testcomplete/index.asp
Unfortunately it's not free.
Reading a list made by Scott Hanselman, I found these two tools:
WatiN, to automated the tests;
WatiN Test Recorder, to automate the test code generation.
From WatiN page:
[...]WatiN (pronounced as What-in) website. Inspired by Watir development of WatiN started in December 2005 to make a similar kind of Web Application Testing possible for the .Net languages.
And from WatiN Test Recorder:
The purpose of the application is to generate code compatible with the WatiN (Web Application Testing In .NET) project.
Have a look at Seleno. It uses Selenium under the bonnet but abstracts all browser automation into Page Objects, which lead to well structured and fluid C# based tests.
It is particularly well suited to ASP.NET MVC, as each Page Object can be strongly typed (using Generics) to an equivalent MVC ViewModel, leading to a consistent relationship between View, ViewModel and Page Object.
Check out some of the samples in the Seleno codebase to see this in action.

Resources