What Is Test Coverage?
Test coverage is a metric that measures the extent to which a test suite exercises the application, expressed as a percentage of code lines, branches, requirements, or features verified by tests.
Free to start · 7-day trial on paid plans
In Depth
Test coverage exists in two flavors: code coverage (how many lines, branches, or paths the tests execute) and requirements coverage (how many specified requirements have at least one associated test). Both are useful but incomplete. High code coverage does not guarantee the tests assert anything meaningful, and requirements coverage misses edge cases not captured in specifications.
The most common code-coverage metrics are line coverage (percentage of executed lines), branch coverage (percentage of decision branches taken), and function coverage (percentage of functions called). Tools like Istanbul/NYC for JavaScript, JaCoCo for Java, and coverage.py for Python instrument the code and generate reports.
Coverage is a helpful diagnostic, not a target. Mandating 100% coverage leads to brittle tests that assert implementation details. A more practical approach is to track coverage trends (is it rising or falling?), set minimum thresholds for critical modules (e.g., 80% branch coverage on payment logic), and use coverage gaps to guide where to add tests next.
Why Interviewers Ask About This
Interviewers ask about coverage to see whether you understand its value and limitations. The best answer acknowledges that coverage is a useful indicator but not a quality guarantee.
Example Scenario
A team achieves 95% line coverage but discovers a production bug in the checkout flow. Investigation reveals the tests execute the discount calculation line but never assert that the output is correct. The line is "covered" but not verified. The team adds assertion-based tests targeting the discount logic.
Interview Tip
Distinguish between code coverage and requirements coverage. Mention that high coverage with weak assertions creates false confidence. Discuss how you use coverage data to find gaps rather than as a pass/fail gate.
Related Terms
Explore related glossary terms to deepen your understanding.
Related Resources
Dive deeper with these related interview prep pages.
Ready to Ace Your QA Interview?
Practice explaining test coverage and other key concepts with our AI interviewer.
Join 1,200+ QA engineers already practicing with AssertHired.
Start Your Free QA InterviewFree to start · 7-day trial on paid plans