.NET Code Coverage Metrics Review

The month of May has really been about answering the question “how do you know if your code is good?”  It’s a question that we at NCover, and every development team around the world, asks themselves on a daily basis.  We have dedicated May to discussing .NET code coverage metrics to help answer that question and we appreciate all of the great feedback we have gotten from folks on our recent posts.  We wanted to finish out the month by providing a brief recap of the key topics we covered and providing links to all of the new resources we made available.

.NET Code Coverage Metrics That Matter

code-coverage-metrics-that-matterWe hosted a live webinar for our largest online audience ever where we reviewed several important metrics that can help development teams measure the success of their testing strategy as well as the overall riskiness of their code base.  Based on the tremendous interest we had in this webinar, we have made a condensed version of the webinar available online for immediate viewing

Although most code coverage tools stop with the basic coverage metrics, we reviewed our approach of bringing transparency to code coverage and how to turn code coverage metrics into actionable items for improving code quality.  In addition, we discussed the importance of looking at code coverage metrics alongside risk management metrics.  We believe this approach not only provides a more complete picture of the overall health of your code but also allows you to better direct limited resources to deliver the best .NET applications possible.

Sequence Point Coverage

Screen Shot 2014-05-12 at 3.03.48 PMWe kicked off the month by reviewing sequence-point coverage, the base code coverage number used by NCover. We also reviewed the advantages of sequence-point coverage over more simplistic coverage metrics like line coverage and statement coverage.

Sequence-point differentiates between each point where the debugger is able to stop when single-stepping through a code file. As a tool focused on .NET code coverage, NCover uses the compiler’s debug symbol database to provide this information, so it is guaranteed to provide the same points that the Visual Studio debugger will use when debugging.  You can find the complete article on sequence-point coverage here.

Branch Coverage

branch_coverageNext, we moved to branch coverage.  Branch coverage measures the fraction of independent code segments that were executed. Independent code segments are sections of code that have no branches into or out of them. These independent code segments are sections of code that you would expect to execute in its entirety every time it’s run.

When comparing branch coverage to sequence point coverage, we shared our philosophy that by relying on branch coverage to measure how well testing efforts are succeeding and sequence-point coverage to highlight exactly which lines of code are not being executed, you can confidently and reliably develop high quality applications.  You can find the complete article on branch coverage here.

Change Risk Anti-Patterns And Code Complexity

cyclomatic_complexityFinally, we wrapped up with the change risk anti-patterns score. Although thoroughly testing code and maintaining high levels of code coverage is one method for mitigating the risk of code, the underlying complexity of that code continues to contribute to its overall risk. This correlation between complexity and code coverage can be quantified and managed by using the change risk anti-patterns score.

Understanding change risk anti-patterns and the the correlation between code complexity and code coverage is crucial for development teams who want to maintain the overall health and quality of their code base.  You can find the complete article on change risk anti-patterns and code complexity here.

Putting Coverage To Work For You

Whether you are a single developer or part of a larger team, we invite you to try the industry’s leading .NET code coverage tool to work for you by downloading a free 21-day trial.  If you would like to discuss any of these topics in greater details or share our thoughts on code coverage best practices, request an online overview and we will work with you one-on-one to explore how to improve your overall code quality.


  1. Anonymous says:


    links in this article are not working…. I will get NOT FOUND error (404) when I will click to details link about branch, sequence or CRAP links

    • Kerry Meade says:

      Eeeckkk! A bug in our post. 🙂 Thanks for the heads up. They have been corrected.


  1. […] .NET Code Coverage Metrics Review (Kerry Meade) […]

  2. […] .NET Code Coverage Metrics Review (Kerry Meade) […]