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. :-)

12 Comments

Comments have been disabled for this content.