Tuesday, January 30, 2007

Getting Code Coverage Without Tests ...

The following steps shows how to get code coverage on .NET applications without having to actually run "tests" in the VSTS context. You will need either VSTS for Developers, VSTS for Testers, or VSTS Team Suite Edition installed to have the right tools to make it work.

Using the commandline you can instrument any .NET assembly, but beware of code signing as it might cause problems. Once the code is instrumtented, you need to get the "listener" running to collect the code coverage data generated, as follows:
  1. Open a VS command prompt
  2. Instrument your assembly by executing:
    vsinstr /coverage Assemblyname.dll
  3. Start the Code Coverage monitoring process by executing:
    vsperfcmd /start:coverage /output:yourfilename.coverage
  4. Run your Application that contains the instrumented code
  5. End the Code Coverage monitoring process by executing:
    vsperfcmd /shutdown
  6. Open the file "yourfilename.coverage" found in your application directory in Visual Studio to view the results.

1 comment:

Anonymous said...

Thanks for the great information, any idea if there is a way to get this .coverage file loaded into the TFSWarehouse so users can use the canned reports to view coverage information?