CRAP Score with NCover 4….

I get questions all day about code coverage, but one of the most common questions is, “How do we get the most out of our coverage metrics?”. The root of this question comes from the transition of taking your coverage data and applying it in a dynamic way to improve your development process. Data doesn’t help by itself; data must provide guidance to positive change.

My response to this question always begins with, “Do an analysis of your cyclomatic complexity and then use your complexity numbers to help prioritize your testing efforts.” If you’ve been in software development for any amount of time you’re well aware that complex code is expensive code — it’s difficult to test, difficult to fix, and difficult to maintain. Complex code results in wasted development time which could be prevented with better understanding of your code’s potential trouble spots.

There’s a newer school of thought which derives from the code complexity conversation. The thought is that if your code reaches high enough levels of complexity, no amount of testing can prevent quality issues, and ultimately there is a correlation between code complexity and necessary testing requirements. This highlights the importance of having clarity on not just your code coverage, but also your complexity numbers.

Historically NCover has provided four metrics: Method Coverage, Branch Coverage, Symbol Coverage and Cyclomatic Complexity. As the importance of the relationship between coverage and complexity became more evident, the NCover team decided to add a new metric which has commonly been referred to in the development world as a CRAP (Change Risk Anti-Patterns) score. This score combines the level of code coverage on a given method with the same method’s complexity number which results in a corresponding CRAP number.

In most circles a CRAP score of 30 or below is considered acceptable, but ultimately you decide what level of complexity and what level of code coverage make sense for your team. To provide flexibility within your environment, NCover 4 allows you to modify the acceptable threshold for not only your complexity numbers, but also your CRAP score. With this flexibility you can experiment with the CRAP score and improve over time.



NCover provides immediate and valuable feedback on your testing efforts — with the addition of the CRAP score, NCover can help you improve not only your tests, but the general health of your code faster and easier than ever before!


  1. This really has the hallmark of a well-written April Fool’s post!