views:

1180

answers:

5

In Visual Studio, I just created a simple Unit Test to test a method I wrote. I wanted to check the code coverage, but the Code Coverage window only ever states that "Code Coverage is not enabled for this test run". Why? Note:

  1. I've already followed the instructions on this page, i.e. the test configuration does have the relevant assemblies checked on the Code Coverage options page.
  2. I've clicked "Run test", not "Debug test", which some sources claim causes this.
  3. I've tried running the test with the current build configuration set to either "Debug" or "Release"; neither works.
  4. I've also followed the suggestions on this page (re-select the testrunconfig file by selecting Test => Select Active Test Run Configuration), to no avail.

Yet I still get the message "Code Coverage is not enabled for this test run" every time I run the relevant test. How do I enable Code Coverage once and for all?

+1  A: 

Take a look at this page and see if that helps: Tips on Using Code Coverage in Visual Studio 2005

He had an issue even after setting the configuration file you mentioned and the issue was related with assemblies located on GAC.

What is GAC? --
Timwi
It stands for Global Assembly Cache.I don't know whether your project uses that, but that's just a possibility.You can try forcing assembling of everything, erasing the current DLLs and objects and building again, with the profiling enabled.
A: 

If this is for a c++ project, ensure that you have Profiling enabled. Bring up your project properties -> Linking -> Advanced. Find Profile and set it to Enable Profiling information (/PROFILE).

Paul Whitehurst
A: 

Be sure to run your tests from the Test View or Test List window... not from the test results window. Re-running tests from within the test results window doesn't always honor your test run configuration settings.

Stephen M. Redd
+1  A: 
Marc Gravell
A: 

It’s broken. Try NCover instead.

Timwi