

One can argue in different ways here, but let us assume that you do agree with me – and you want to get this result more correct 🙂 I want to see the code coverage of the real production code, and would have expected a result of 50% in this case. Some people find this to be just fine, and want the code coverage to include the tests.

We also see all the tests, which – not surprisingly – is at 100%. The total code coverage is calculated to 88%. For this demonstration I have used multiple different test frameworks just to show that this applies to any of these frameworks.Īll the tests we have tests the Add method, none tests the Subtract method, so the expected code coverage should be 50%. It can do so for (nearly) any type of adapter you choose to use, MSTest, CPPTest (managed/native), XUnit and NUnit (but not Chutzpah (note 1)).Īssume you have a project with a set of unit tests included. The VS2012/13 unit test feature can generate code coverage results. Download: VS2012 Runsettingstemplate VS2013 Runsettingstemplate
