How to enable and generate unit test code coverage metrics in your VS2010 solution

Right click on the solution >> Add file >> Add a test settings file

After it is added, VS will open a prompt for the test settings.

Go to the Data and Diagnostics section, select code coverage and then click configure (left top in the same section as the checkboxes). Select all projects you want to have code coverage metrics for, other than the unit test project.

Close this window, and then click apply. Remember: You can get back to this, by going to the Test menu on the top, "Edit Test Settings" and selecting the new test settings created.

Now run all tests in the solution, and after they have completed execution, click on the "Show Code Coverage Results" icon on the extreme right top of the test results pane.

You can now expand the heirarchy and see the code coverage results.

If you get this error: "Strong name verification failed for the instrumented assembly Please ensure that the right key file for re-signing after instrumentation is specified in the test settings."

Just set the strong key in the configuration page where you selected the assemblies for the code coverage.

Comments

Popular posts from this blog

Tutorial: Using Google Cloud Storage from C# and .NET

Late 2008 Macbook only giving 1.5 gb/s speed with 6 gb/s Intel SSD?

Enable Visual Studio to use more than 2GB of memory