Skip to content
Hiep Lam
Go back

Beyond Coverage, Part 0: Why Coverage Lies (and What Your Instinct Gets Right)

Edit page 🇻🇳 Tiếng Việt

“Beyond Coverage: Test Quality for the Agentic Loop” - Part 0 of 7. Why code coverage is a valid warning sign but a false reassurance, and what it would actually take to trust a suite. This series distills a multi-agent deep-research pass - 27 sources fetched, 127 claims extracted, the load-bearing ones put through adversarial verification - into a practical answer for a legacy Go + .NET codebase moving toward an AI-driven merge gate.


Four gates, and coverage only checks the first

A test catches a bug only if it passes four gates, in order. Software-testing researchers call this the R-I-P-R model:

  1. Reachability - the test executes the faulty line.
  2. Infection - the bad code actually corrupts program state for that input.
  3. Propagation - the corrupted state reaches an observable output.
  4. Reveal - an assertion inspects that output and fails.

Coverage stops measuring at gate 1. Everything that makes a test valuable - infection, propagation, and especially the assertion that reveals the fault - is invisible to coverage.

The R-I-P-R funnel: coverage only proves reachability, not that a test would catch a bug Four gates stand between “the test ran this line” and “the test would catch a bug here” - coverage only proves the first.

This is why a suite can show 90% line coverage and still be blind: it runs all the code and asserts nothing meaningful.

The evidence

Coverage is sensitive to execution, not verification. As one practitioner analysis puts it bluntly, “code coverage is only sensitive to execution, but … not sensitive to actually testing / verifying / asserting outcomes.” High coverage “can coexist with tests that assert nothing and catch zero regressions.” The same source frames coverage’s only honest use: a valid negative indicator - low coverage tells you where you are blind; high coverage tells you nothing about quality. [optivem]

The oracle gap is real and measured. A 2023 empirical study of coverage vs. mutation score across a large corpus found the two are positively but not perfectly correlated: they track each other at low coverage, but “better-covered files show significantly more variation, with frequent large positive gaps between coverage and mutation score - indicating code that is executed, but poorly checked.” ✅ (adversarially confirmed, 3-0) [oraclegap]

The concrete, damning number from the same study: among 26 files with > 80% statement coverage and < 20% mutation score, at least 12 had multiple missing assert statements - tests that ran the code but failed to catch obvious injected defects. ✅ (confirmed, 3-0) [oraclegap]

Scatter plot of coverage vs mutation score per file, showing a wide gap below the diagonal Each dot is a source file. The distance below the diagonal is code that’s run but not actually verified - the “oracle gap.”

Branch coverage doesn’t save you either. A 2021 industrial study found branch coverage and mutation coverage agree for only 47% of classes, with a weak rank correlation (Kendall τ-b ≈ 0.25). In 8% of classes, branch coverage was high while mutation coverage was low - the tests walked every path but caught none of the injected faults. The authors conclude “using branch coverage alone can mislead a developer about [the] quality of the tests.” ✅ (confirmed, 3-0) [branchcov]

Coverage barely predicts real defects. A study of Apache systems found “dynamically computable test characteristics like code coverage have a relation to post-release defects, but only marginal.” [apache]

Goodhart’s law: the moment you target coverage, it dies

“When a measure becomes a target, it ceases to be a good measure.”

The .NET author Mark Seemann argues directly that coverage as a mandated target is self-defeating - “people respond to incentives, although not necessarily in ways that are predictable.” Tell a team (or an AI agent) to hit 80% coverage and they will hit 80% coverage: by writing assertion-free tests, trivial getter tests, and Assert.NotNull rituals that execute code and verify nothing. [ploeh] The metric goes green; the suite gets worse, because now it’s full of noise that looks like protection.

This matters doubly for the agentic loop. An LLM told to “increase coverage” is an extremely efficient Goodhart machine - it will generate exactly the vacuous tests that satisfy the letter of the metric, a failure mode we’ll measure directly in Part 5.

So is coverage useless? No - it’s a floor, not a ceiling

Keep coverage, but demote it to its honest job:

The rest of this series is about the metrics that measure the part coverage can’t: does the suite actually notice when the code is wrong? Part 1 lays out the whole catalog, layer by layer.


Sources


Next: Part 1 - The Metric Catalog →

The series - Beyond Coverage: Test Quality for the Agentic Loop: 0 · Why Coverage Lies (you are here) · 1 · The Metric Catalog · 2 · Mutation Testing, Properly Explained · 3 · What the Empirical Research Actually Says · 4 · Tooling for Go and .NET · 5 · Grading AI-Generated Tests · 6 · The Readiness Rubric


Edit page
Share this post:

Previous Post
Compile Once, Maintain Forever: Karpathy's LLM Wiki Pattern
Next Post
Beyond Coverage, Part 1: The Test-Quality Metric Catalog

Keep reading

A few more pieces in the same vein.

Rather read on your own time? Subscribe via RSS