Enabling Code Coverage for the first time in Visual Studio 2010 isn’t obvious, once unit tests are completed and running the following steps are required.
- Select the testsettings file in Solution Items and open it.
- Select Data and Diagnostics
- Select Code Coverage and check the Enabled check box
This enables a ‘Configure’ button, this is the bit that isn’t obvious, using the Configure button you need to select the ‘artifacts to instrument’, without this Code Coverage will be configured to run but no code will be checked.
As shown below.