Code Coverage
Code coverage measures the proportion of lines/branches/functions/paths of code executed by tests, assessing test adequacy.
Purpose
Quantify test coverage, identify untested code, and guide test supplementation.
Mechanism
Instrumentation records whether each line/branch executes. Line coverage: executed lines / total lines. Branch coverage: executed branches / total branches. MC/DC coverage is used for safety-critical systems. Istanbul/nyc for JS, gcov for C.
Use cases
- Test quality assessment
- Test supplementation guidance
- CI gates