Search code examples
unit-testingvisual-studio-2012mstestcode-coverage

VS2012 Code Coverage For Assemblies Not Covered By Tests Yet


I'm using code coverage in VS2012 premium as a diagnostic tool.

It appears to only provide code coverage results for assemblies that have code touched by a test.

I have some assemblies that aren't tested at all, I would like these to show as 0% coverage, rather than be ignored completely.

How can I force them to be covered?

I have a custom CodeCoverage.runsettings file that explicitly includes these assemblies, but they are still ignored.

Thanks, Tim


Solution

  • I think this is by design. Check those assemblies loaded during the test run. You can only see the coverage of the code/assemblies loaded by your tests. In other words during your test execution, those assemblies must loaded into the memory so they can be instrumented. I think some other third party coverage tools shows the coverage if non instrumented assemblies but I'm not sure.

    From MSDN:

    Code coverage analysis is done while tests are running. It only includes assemblies that are loaded into memory when the tests run. If none of the tests are executed then there is nothing for code coverage to report.

    http://msdn.microsoft.com/en-us/library/jj159523.aspx