intermediate 2 min answer

Leadership mandates 80% code coverage across all services. What do you say?

metricstestinggovernance
Show the full answer Hide the answer

What the interviewer is testing

Whether you can push back on a metric constructively, offering something better rather than objecting.

The problem with the mandate

Coverage measures execution, not assertion. A test that calls a function and asserts nothing produces coverage. When a number becomes a target, that is exactly the test people write — which is Goodhart's law operating inside a pipeline.

A uniform threshold is wrong in both directions. For the payment calculation engine, 80% is far too low; for a generated data-access layer or a thin controller, chasing it produces tests that assert nothing and must be maintained forever.

Legacy code makes it unreachable, so the mandate is either ignored or drives a burst of low-value test writing to clear the bar.

What to propose instead

Coverage on changed lines, not on the codebase. New and modified code must be covered; the existing backlog is left alone. This is achievable immediately, targets behaviour where it can change, and is the single most useful reframing.

Ratchet rather than threshold: overall coverage must not decrease. Simple, achievable, and it moves in the right direction without a cliff.

Tier by consequence. High-consequence logic — pricing, entitlement, financial calculation, tax, safety limits — warrants a much higher bar plus mutation testing, which measures whether tests actually detect broken code. Low-consequence code warrants less.

Report the metric that leadership actually wants. They are asking for coverage because they want fewer production defects. Change failure rate and escaped defect count measure that directly, and are harder to game.

What a strong answer adds

Offering mutation testing on changed code in the pull request for the high-consequence tier. It directly answers "are these tests any good", which is the question underneath the coverage request, and it is affordable when scoped to the diff.

Common weak answers

"Coverage is a useless metric" with no alternative. Complying and producing assertion-free tests.