Guidelines and Standards for Setting Code Coverage Targets in Software Testing
The article reviews typical code‑coverage goals such as 70‑80% for system testing, explains how factors like failure cost, resource constraints, testability, and development stage influence target selection, discusses why full coverage is often impractical, and summarizes major industry standards and coverage metrics used in safety‑critical domains.
For most projects with coverage metrics, a reasonable system‑testing goal is 70‑80% code coverage, while higher‑risk or safety‑critical systems may require 80‑90% or more, especially for unit tests.
Target selection should consider:
Failure cost : Increase targets for safety‑critical or high‑cost‑failure systems (e.g., medical, automotive).
Resources : Reduce targets if testing staff are insufficient or lack training.
Testable design : Raise targets when the system allows direct access to internal functions.
Development‑cycle state : Lower targets for legacy systems without original designers.
Many projects do not set a strict minimum coverage; they use coverage analysis mainly to identify untested areas and avoid over‑estimating coverage early on.
Achieving 100% coverage is often unrealistic and uneconomical; high coverage does not guarantee fault detection, and the cost of exercising rarely‑triggered test cases can outweigh the benefits.
Key reasons full coverage is impractical include high cost of low‑probability test cases, hidden errors in lower‑level code, future‑code accessibility, and shared code not exercised by all projects.
When coverage goals become the primary focus, the motivation shifts away from fault detection.
Coverage metrics commonly used for control‑flow analysis are:
Statement (line) coverage
Basic‑block coverage
Decision (branch) coverage
Condition/decision coverage
Modified condition/decision coverage (MCDC)
Major standards addressing code coverage:
DO‑178B (aviation): Requires 100% coverage for safety‑critical software.
IEC 61508 (functional safety): Recommends 100% coverage for certain metrics, with strictness depending on safety integrity level.
ISO 26262 (automotive): Requires coverage measurement and justification when coverage is insufficient; suggests different metrics for unit and integration testing.
ANSI/IEEE 1008‑1987 : Mandates 100% statement coverage and recommends 100% branch coverage for critical code.
FDA guidance for medical devices : Calls for structural coverage proportional to software risk, without specifying exact percentages.
These standards define coverage requirements in the context of risk analysis, safety integrity levels, and functional safety, but often leave the exact metric definitions to the implementer.
References include studies on efficient use of code coverage, its relation to quality, empirical analyses of branch coverage, and guidance on testing completeness.
Continuous Delivery 2.0
Tech and case studies on organizational management, team management, and engineering efficiency
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.