Skip to content

What do the coverage values mean?

irongut edited this page Nov 25, 2021 · 16 revisions

Code Coverage Summary provides a useful set of metrics to help you improve the quality of your code but what do the values actually mean?

Code Coverage

Package Line Rate Branch Rate Complexity Health
Company.Example 83% 69% 671
Company.Example.Library 27% 100% 11
Summary 83% (1212 / 1460) 69% (262 / 378) 682

Minimum allowed line rate is 50%

Line Rate

Line Rate is the ratio of the number of lines of code executed by your tests to the total number of lines of code. Line rate is similar to statement rate but the correspondence between statements and lines isn’t always one to one. Depending on the programming language, a statement can span multiple lines and a single line could contain multiple statements.

Branch Rate

Branch Rate is the percentage of branches in a codebase that are executed by your tests. A branch is one of the possible execution paths the code can take after a decision statement is evaluated.

Branch Rate is an important metric that can help a team or organization assess whether an application has been tested to completion. A low branch rate shows that there are scenarios in the application that lack testing. Such scenarios might contain defects that will only manifest in edge cases when the application makes it into production.

Complexity

Cyclomatic complexity measures the number of possible paths execution could take through a given method or function. Simple functions that have no branching will have a complexity of 1. A complex method with many different if clauses and / or switch statements will have a much higher complexity score. When analyzing code to look for problem areas, identifying the highest complexity values is often a good place to start.

When analyzing classes with auto-properties or many small methods, you'll frequently see complexity values of 1 because each get and set method will have a complexity value of 1. This makes it difficult to use cyclomatic complexity as a heuristic for classes, namespaces, projects or assemblies. Cyclomatic complexity is only really useful as a method or function metric, it breaks down at class and higher levels.

The Summary complexity value provided by CCS is the sum of the individual package values.

Clone this wiki locally