#1
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:

  1. Statement Coverage (or Line Coverage): Measures whether each executable instruction or statement has been run at least once. This is the most basic metric.
  2. 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.
  3. 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
    .
  4. Function/Method Coverage: Determines if every function or method in the codebase has been called during the test run.
By analyzing multiple code coverage metrics, teams can build a comprehensive testing strategy that addresses not just what lines were run, but what logical paths and conditions were thoroughly validated, leading to a much higher degree of confidence in the final software product.
 

Forum Jump: