11 hours ago
Code coverage metrics are specific, quantifiable measures used to detail how a test suite exercises the source code, moving beyond the simple percentage of lines hit. These metrics provide a fine-grained view of testing thoroughness, allowing teams to identify and focus on different dimensions of risk within the codebase.
Key code coverage metrics include:
Key code coverage metrics include:
- Statement Coverage (or Line Coverage): Measures whether each executable instruction or statement has been run at least once. This is the most basic metric.
- Branch Coverage (or Decision Coverage): Ensures that every possible logical path in a control structure (e.g., both the
TRUE
and
FALSE
outcomes of an
if
statement) has been executed. This is significantly more rigorous than statement coverage.
- Condition Coverage: Assesses whether every boolean sub-expression within a condition (e.g., in
if (A AND B)
) has been evaluated to both
TRUE
and
FALSE
.
- Function/Method Coverage: Determines if every function or method in the codebase has been called during the test run.