JG Vimalan's Blog

It is all about coding!

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.


December 9, 2010 - Posted by | TFS, VS 2010

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: