Testing With NCover/NCoverExplorer

The following screencast demonstrates how to achieve 100% coverage using TestDriven.NET 2.0, NCover and NCoverExplorer. Peter Waldschmidt and Grant Drake very kindly agreed to let me distribute NCover and NCoverExplorer with the RTM version of TestDriven.NET 2.0. This means that once TestDriven.NET is installed, there is nothing more to configure. Code coverage with NCover can be used from Visual Studio .NET 2002, 2003 or 2005. It is possible to use NCover if only .NET 1.1 is installed, however .NET 2.0 is recommended. If only .NET 1.1 is installed then NCover 1.3.3 will be used rather than the more mature NCover 1.5.6.

In the screencast I start off by showing how to zoom in on the partially covered regions of code. I then navigate back to Visual Studio and expand my unit test to cover all of the partially covered method. Rather than create a unit test for the ToString method, I decide to use the 'Coverage Exclude' feature of NCover 1.5 (TestDriven.NET uses "//ea CoverageExcludeAttribute" by default). I create a new CoverageExcludeAttribute and use it on the ToString method (extra assembly references are required). This enables me to achieve 100% coverage with the excluded code grayed out and not counted in the final coverage score.


You can watch the screencast here.

I'd like to thank Grant Drake in particular for his support, generosity and convincing me that it was worth carrying on with the project. :-)

Published Saturday, November 11, 2006 8:29 AM by Jamie Cansdale


# re: Testing With NCover/NCoverExplorer

Looks great (again!)

One question regarding the coverage configuration. Most of the unit testing I work with is in a separate DLL to the code being tested. Normally I have a script that fires off NUnit with NCover on the test (e.g. App.UnitTests.dll) and target DLL (e.g. App.Common.dll). That way I see the coverage on both the tests and the tested code.

Is there a way to configure that through TestDriven.NET or will I need to continue doing the separated DLL test manually?

Tuesday, November 21, 2006 4:54 AM by Paul Kohler

# re: Testing With NCover/NCoverExplorer

Great screencasts Jamie !!

God way to teach us to use all the potential of Testdriven !!

Let me ask you an offtopic: what screen record program are you using to create these screencast, sorry for ask, and you cant of course don't ask it to me.

Cheers and keep in the outstanding work


Friday, November 24, 2006 3:24 PM by Marcos

# re: Testing With NCover/NCoverExplorer

Paul - by default it will do coverage on all assemblies with PDB info in the output directory. It should behave as you expect. It is possible to exclude the test assembly from inside NCoverExplorer.

Thursday, December 7, 2006 4:28 AM by Jamie Cansdale

# re: Testing With NCover/NCoverExplorer

Marcos - the screencasts were done using BB Flashback.

Thursday, December 7, 2006 5:19 PM by Jamie Cansdale

# re: Testing With NCover/NCoverExplorer

Dirk - I'm afraid there's no way to specify a different attribute at the moment. I'll add that as a feature request.

Thursday, December 7, 2006 5:22 PM by Jamie Cansdale

# re: Testing With NCover/NCoverExplorer

Does ncover support asp.net 2.0 ?

I can't profile the asp.net 2.0 web site application...How to do ?

Wednesday, March 28, 2007 5:56 AM by globe

# re: Testing With NCover/NCoverExplorer

I've done everything in the screencast but it won't exclude any methods. What could I be doing wrong? Do I need particular versions of the softwares?

Monday, June 25, 2007 1:18 AM by James Cook

# re: Testing With NCover/NCoverExplorer

Testing With NCover_2F00_NCoverExplorer.. Great! :)

Thursday, May 12, 2011 8:49 AM by weblogs.asp.net

# re: Testing With NCover/NCoverExplorer

Testing With NCover_2F00_NCoverExplorer.. Tiptop :)

Sunday, June 26, 2011 11:17 AM by weblogs.asp.net

# re: Testing With NCover/NCoverExplorer

Wow! I could not even guess about it)) Not bad.

Wednesday, March 28, 2012 10:02 AM by Jordan

# re: Testing With NCover/NCoverExplorer

i like your post,thanks

Saturday, December 29, 2012 12:28 AM by iphone cases

# re: Testing With NCover/NCoverExplorer

I never heard this post ago.

Tuesday, April 30, 2013 10:03 AM by iPhone 5 Cases