If you want to enable code coverage in Microsoft Visual Studio 2010 for you’re unit tests. Add a Test Project to you’re solution: File > Add > New Project… > Visual C# > Test > Test Project.

This will automatically add the solution files “Local.testsettings”, “TestProject1.vsmdi” and “TraceAndTestImpact.testsettings”.

Double click  the “Local.testsettings” file > Data and Diagnostics > Check “Code Coverage”, then select the Code Coverage row and click on Configure


Check the assemblies you want the code coverage to be generated and click on OK.

When you run you’re unit tests the code coverage will be generated (I added functions that are and are not covered by any unit tests to show the result)


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.