-
-
Notifications
You must be signed in to change notification settings - Fork 58
What do the coverage values mean?
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?
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 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 the primary coverage type for CCS - it determines the coverage badge, health indicator and whether the action passes or fails.
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.
Is Branch Rate better than Line Rate? No, branch rate only measures conditionals and does not measure coverage of sequential code but it is an important metric that can help 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. Hence it is recommended to look at both metrics together.
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.