Friday, June 5, 2009

Enabling code coverage in Visual Studio 2008 - "Code Coverage is not enabled for this test run"

After right clicking on a Test Result and selecting "Code Coverage Results" I'm taken to the Code Coverage Results area and shown the message "Code Coverage is not enabled for this test run". To enable it:

  • Test > Edit Test Run Configurations > Local Test Run (...)
  • Code Coverage
  • Check the artifacts/DLLs that you want to see code coverage for.

If you get the message "Code coverage instrumentation warning while processing file FooBar.dll:
Warning VSP2013 : Instrumenting this image requires it to run as a 32-bit process. The CLR header flags have been updated to reflect this." try unchecking Instrument assemblies in place

See also: Code Coverage is not enabled for this test run
TESTTOOLSTASK : warning VSP1024: Unable to open file 'file' for writing.