Code Coverage Tips

I thought I'd share a couple of code coverage FAQs.

  1. How do I merge the code coverage results from multiple test projects?
  2. 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'.

2 Comments

  • Is TestDriven.dll.config the right name? I didn't think that a dll would use a config file, since it's in process of an exe?

    I have a TestDriven.config, but if I add the lines that you suggest, then nothing seems to change at all.

    Cheers,

    Martin.

  • Heya i抦 for the first time here. I came across this board and I find It really useful & it helped me out a lot. I hope to give something back and help others like you helped me.

Comments have been disabled for this content.