I'm trying to get code coverage working in VS2012 premium, and I'm having some trouble.
I have a C# solution with a few different projects, but most notably a Kernel.dll to be tested and a Kernel.Tests.dll that tests using NUnit and Rhino Mocks.
Using the NUnit Test Adapter (Beta 2), getting the tests into the test explorer works fine, as does running them. But when it comes to code coverage, I only get analysis from the test dll itself, not the code that is tested. This is when I do not use a .runsettings file.
I have also tried using a .runsettings file (like here: http://msdn.microsoft.com/en-us/library/jj159530.aspx) with this specification:
<Include>
<ModulePath>.*\.dll$</ModulePath>
</Include>
<Exclude>
<ModulePath>.*\.Tests\.dll$</ModulePath>
</Exclude>
but this just gives me an empty result, because now the test dll doesn't get included either.
The problem seems to be that it doesn't find the other parts of the solution, but I'm not sure where exactly it looks, or what I need to set up in order for it to be found.
Has anyone run into the same issue? Any ideas on how to fix it?
To calculate the code coverage percentage, simply use the following formula: Code Coverage Percentage = (Number of lines of code executed by a testing algorithm/Total number of lines of code in a system component) * 100.
Code Coverage Analysis is the process of discovering code within a program that is not being exercised by test cases. This information can then be used to improve the test suite, either by adding tests or modifying existing tests to increase coverage.
Excluding code from code coverage The easiest way to exclude code from code coverage analysis is to use ExcludeFromCodeCoverage attribute. This attribute tells tooling that class or some of its members are not planned to be covered with tests.
It sounds like there may be an issue with the NUnit Test Adapter itself. I read on the Visual Studio Gallery Q&A section that they have already fixed bugs to do with the test adapter and debugging assemblies linked by the test assembly. This sounds related to me, so you may want to file a bug here: https://bugs.launchpad.net/nunit-vs-adapter/+filebug
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With