Back to Test metrics
Test

Test coverage (code coverage)

The percentage of production code exercised by at least one test — a floor metric for finding test suite gaps.

testcoveragecode-quality

// Formula

covered LOC÷total LOC×100%

// About this metric

Test coverage (typically measured as line coverage or branch coverage) shows what proportion of your codebase is executed when your test suite runs. It is produced by coverage instrumentation tools — Istanbul/NYC for JavaScript, JaCoCo for Java, Coverage.py for Python — as part of the test run.

Coverage measures what tests touched, not what they verified. A test that calls a function but makes no assertions will still increase coverage. This is why coverage is best thought of as a floor metric: low coverage is definitely a problem (there are large areas of code with no tests at all); high coverage is not necessarily a success.

The World Quality Report (2024–25) reports an industry average test coverage of approximately 70% for commercial software teams. The commonly cited "80% coverage" target emerged from empirical observation that teams below this threshold tend to have more production defects, while coverage above 80% shows diminishing marginal returns in defect detection.

Branch coverage is a stricter measure than line coverage: it requires tests to exercise both the true and false paths of every conditional, not just execute the line. If your coverage tool supports it, branch coverage is more informative for complex logic.

// Calculator

🧮 Calculator

Your test coverage75.0%

// Benchmark

You're in the 'Typical' range — 75.0 %.

Source: World Quality Report 2024-25 industry average ~70%

Coverage measures what tests TOUCHED, not what they VERIFIED. 90% coverage with weak assertions is worse than 60% coverage with strong assertions.

// When to use this metric

Use coverage to find untested areas of the codebase — it is a gap-finding tool, not a quality-scoring tool. The most valuable coverage analysis is differential: "which lines changed in this PR have no test coverage?"

Don't use coverage as a quality target or incentive metric. Teams optimising for coverage will write tests that execute code without asserting anything meaningful, producing high coverage scores with low testing value.

// Common pitfall

Coverage tells you what code your tests touched, not what they verified. 90% coverage with no assertions is worse than 50% coverage with strong property-based tests. Treat coverage as a floor (sound the alarm when it drops), not a goal (don't celebrate when it rises artificially).