What is Code Coverage?
Code coverage is a metric that measures the percentage of source code executed during automated testing.
Code coverage is a metric that measures the percentage of source code executed during automated testing. It indicates how thoroughly your test suite exercises the codebase, typically measured as line coverage, branch coverage, function coverage, or statement coverage.
Line coverage measures the percentage of code lines executed by tests. Branch coverage measures whether both true and false paths of conditional statements are tested. Function coverage measures whether every function has been called. Branch coverage is generally considered the most meaningful metric.
High code coverage (>80%) doesn't guarantee code quality — you can have 100% coverage with terrible tests that assert nothing. But low code coverage (<40%) almost always indicates high risk. Code without tests is code you're afraid to change, which is the definition of legacy code.
The relationship between code coverage and technical debt is inverse: as coverage decreases, the cost of making changes increases because every modification carries unverified risk. Teams with low coverage deploy less frequently, have higher change failure rates, and spend more time on manual QA.
Why It Matters
Code coverage directly impacts deployment confidence, change velocity, and bug rates. Teams with >80% branch coverage deploy 3-5x more frequently than teams with <40% coverage. For investors performing due diligence, code coverage is a proxy for engineering discipline and codebase health.
How to Measure
1. **Line Coverage**: % of code lines executed during tests. Target: >80%.
2. **Branch Coverage**: % of conditional branches tested. Target: >70%.
3. **Critical Path Coverage**: Coverage specifically on revenue-generating or safety-critical code paths. Target: >90%.
4. **Trend**: Is coverage increasing or decreasing over time? Decreasing coverage is a leading indicator of debt accumulation.
Frequently Asked Questions
What is good code coverage?
80%+ line coverage is considered good. 70%+ branch coverage is considered good. More important than the number is the trend — coverage should be stable or increasing, never decreasing.
Does 100% code coverage mean no bugs?
No. Code coverage measures execution, not correctness. You can have 100% coverage with tests that never assert anything. Coverage is a necessary but not sufficient condition for quality.
How much does low code coverage cost?
Teams with <40% coverage spend 2-3x more time on manual testing, deploy 3-5x less frequently, and have 2x higher change failure rates — all of which translate to higher engineering costs.
Related Terms
Need Expert Help?
Richard Ewing is a Product Economist and AI Capital Auditor. He helps companies translate technical complexity into financial clarity.
Book Advisory Call →