TestMatrix: Code Coverage

Unit tests are for testing your application code, code coverage is for testing your unit tests. Without some way to track your code coverage, it's difficult to determine if your application has adequate testing. TestMatrix helps you improve the quality of your code by making it easy to determine which code is not fully covered by automated unit tests. While high coverage is no guarantee of good tests, anything less than 100% coverage is a sure sign that you have untested code. This then becomes your target, a goal to work against as you develop your tests. Integrating code coverage into unit testing practices helps you figure out when you are really finished, and helps you see if you code has drifted away from your tests over time as tiny changes sneak in without a corresponding test.

Track your coverage automatically while you test

Automatic code coverage helps ensure proper levels of coverage throughout your solution by tracking coverage each time your run your unit tests. Solution level coverage information is displayed in the Coverage Profiler panel as well as the editor itself, and includes line, method, and class level coverage statistics.

Editor highlighting to see what you're missing

Code coverage information is displayed directly in the code editor. Any lines of code not covered by your automated unit tests will be marked with a red bar, making it easy to know what you are missing. This happens automatically, with each test run. There is no external programs to run or options to configure, if you have uncovered code you'll know it.

Analyze coverage across the entire solution

The Coverage Profiler panel provides aggregate coverage information across the entire solution. It provide coverage statistics at the solution, namespace, class, method, and line levels. Results are presented in a sortable list view. Click on the class names to jump into the editor where you can examine line level coverage markers. A tolerance slider lets you hide tests with an acceptable level of coverage, so that you can focus on the worst offenders. For example, if you are shooting for 80% coverage set the tolerance slider and the list will only include classes with worse than 80% coverage. This lets you tackle the worst offenders first, because after all some coverage is better than none at all.

Export coverage results as XML

You can export your application's coverage information in XML format. This makes it easy to generate coverage reports, track coverage over time, and collect other metrics. From the Coverage Profiler's file menu, just select Export as XML.