Code Coverage Tips
I thought I'd share a couple of code coverage FAQs.
- How do I merge the code coverage results from multiple test projects?
- I'm using VS2005 Team Suite/Developer/Tester -- is it possible to use NCover/NCoverExplorer?
To merge the code coverage results from multiple test projects, you need to select all of the test projects you want to execute. You can do this by holding down 'Ctrl' and selecting the projects in the 'Solution Explorer' window. Once you've done this you can 'Test With... Coverage' and all of the test run results will be merged. This technique works with NCoverExplorer and Team Coverage.
By default the coverage test runner will use Team Coverage if a Team version of Visual Studio 2005 is being used. If Team Coverage isn't available it will request the user to install Peter Waldschmidt's NCover. It will then use Grant Drake's NCoverExplorer for coverage visualisation. It is testament to what a fantastic job Peter and Grant have done that so many people have asked to use NCover/NCoverExplorer - even when they're using a VS2005 Team edition!
At the moment to make this possible you will need to tweak TestDriven.NET's .config file, which you can find here:
%ProgramFiles%\TestDriven.NET 2.0\TestDriven.dll.config
You need to change the typeName of the 'Coverage' testRunner to be NCoverCoverageTestRunner instead of CoverageTestRunner.
It would also be possible to have two menu items -- 'Test With... NCover' and 'Test With... Team Coverage'. I will however leave this as an exercise for the reader. ;-) Hint, the other coverage test runner type is called 'TeamCoverageTestRunner'.