Skip to main content
Automation
DEFINITION

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. It is useful for finding untested code and misleading as a target, because a test can execute a line without asserting anything about it.

No account needed · Scored in under a minute against a senior rubric

IN THE INTERVIEW

How is Code Coverage asked in interviews?

How do you measure test coverage and is 100% coverage a good goal?

Show the model answer

100% code coverage is not a useful goal, it encourages testing trivial code while missing important scenarios. Coverage types: (1) Code coverage - lines/branches executed (measured by Istanbul/c8). (2) Requirements coverage - which requirements have test cases. (3) Risk coverage - which high-risk areas are tested. Better metrics: critical path coverage (are all business-critical flows tested?), mutation testing score (do tests actually catch bugs?), and escaped defect rate (how many bugs reach production?). Aim for high coverage of critical paths, not arbitrary coverage percentages.

IN DEPTH

What does Code Coverage mean in practice?

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 IT MATTERS

Why do interviewers ask about Code Coverage?

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

What does Code Coverage look like in a real project?

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.

TIP

How should you talk about Code Coverage in an interview?

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.

FREE TOOLS  /  no signup

Free QA career tools, no account needed

Instant and private, everything runs in your browser. Try them before you sign up.

EXEC.NOW

Ready to Ace Your QA Interview?

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

Join 700+ QA engineers already practicing with AssertHired.

Question 1 · Automation · Mid-levellive scoring

A test passes locally but fails in CI about one run in five. Walk me through what you check first, and why.

This single answer is scored on four dimensions: Technical accuracy · Coverage · Clarity · Best practices.

Rather skip ahead? Create a free account

FREE  ·  7-DAY TRIAL
Written by , Senior QA Automation Engineer, 50+ QA candidate interviews conductedLast updated July 2026