Enable code coverage in VS 2010
Developers add unit tests for every method they write and it ensures quality of the application. To know the lines of code they have covered via unit tests, the code coverage should be enabled. Code coverage tells the developers, the various scenarios (using unit tests) they have covered for testing the methods. To enable code coverage follow the steps below,
a. I assume that, your application has a unit test project and a test list with unit test methods added to it. So, as a first step, in visual studio 2010 ultimate, goto Tests->Edit Test Settings ->Local (local.testsettings) as shown in the image below,
b. Now, the Test Settings dialog will appear. Select ‘Data and Diagnostics’ tab. Select ‘Code Coverage’. Click on the ‘Configure’ link as shown in the image below,
Now, you will get a dialog window where you can select the assemblies, projects that come under your unit test.
c. Run the unit tests now.Once the test results are displayed, to view the code coverage results, Goto Tests->Windows->Code Coverage Results.
d. The code coverage results will be displayed as shown below,
Normally, code coverage of 85% is considered to be good.
No comments yet.