Skip to main content
Automation

What Is Code Coverage?

Code coverage is a metric that measures which lines, branches, or paths of source code are executed by automated tests, typically expressed as a percentage and generated by instrumentation tools.

Free to start · 7-day trial on paid plans

In Depth

Code coverage tools instrument source code (or bytecode) to track which lines execute during test runs. Line coverage reports the percentage of source lines executed. Branch coverage checks whether both sides of every conditional (if/else, switch cases, ternary operators) are exercised. Path coverage, the most thorough, tracks every unique execution path through a function, though it is often impractical for complex code due to combinatorial explosion.

Popular tools include Istanbul/NYC for JavaScript/TypeScript, JaCoCo for Java, coverage.py for Python, and SimpleCov for Ruby. Most CI systems can integrate coverage reports and fail builds that drop below a configured threshold. Some teams use coverage-gating on pull requests to ensure new code is covered.

The key insight for practitioners is that coverage measures execution, not verification. A test that calls a function without asserting its return value adds line coverage but no quality assurance. Coverage is most valuable as a gap-finding tool: low-coverage areas indicate untested code that might harbor bugs. It should guide testing priorities, not define quality.

Why Interviewers Ask About This

Interviewers ask about code coverage to test whether you understand the distinction between measuring execution and verifying correctness. They want nuanced discussion, not just naming tools.

Example Scenario

A PR adds a helper function with three branches (success, validation error, network error). The coverage report shows 67% branch coverage because no test triggers the network-error path. The reviewer requests an additional test that simulates a network failure, raising branch coverage to 100% for that function.

Interview Tip

Name specific coverage types (line, branch, path) and tools for your language. Discuss the difference between "covered" and "tested" and how you use coverage reports in code reviews.

Ready to Ace Your QA Interview?

Practice explaining code coverage and other key concepts with our AI interviewer.

Join 1,200+ QA engineers already practicing with AssertHired.

Start Your Free QA Interview

Free to start · 7-day trial on paid plans

Written by Aston Cook, Senior QA EngineerLast updated: March 2026