Test coverage
Test coverage is the percentage of code (typically measured by line, branch, or function) exercised by the test suite. Coverage is a necessary-but-insufficient quality signal: low coverage indicates untested code; high coverage doesn't guarantee correctness because the tests may exercise without asserting.
Coverage targets are contentious. Common defaults are 80% line coverage for application code, 100% for critical paths (security, payment, auth). The trap of coverage-as-goal: writing tests to hit a number produces low-quality tests that exercise without verifying. The trap of coverage-as-vanity: high coverage on uninteresting code (getters, constants) inflates the number while the hard parts remain undertested. The pragmatic discipline: use coverage to surface uncovered critical-path code, not as a metric to maximise. Pair coverage with mutation testing for a stronger signal of test effectiveness.
Related terms
- Code coverage
Code coverage is the percentage of source code executed by a test suite, broken down by statement, branch, or line.
- Mutation testing
Mutation testing measures test quality by introducing small bugs (mutations) into the source code and checking whether tests catch them.
- Test pyramid
The test pyramid is the testing-strategy heuristic that recommends many fast unit tests at the base, fewer integration tests in the middle, and very few slow end-to-end tests at the top.