One executed line is a very small claim

A line of code can be executed by a test and still be wrong. That gap is the entire story behind coverage percentages, and it is written plainly in the manuals of the tools that produce them. coverage.py describes itself as a program that monitors what ran, notes which parts executed, and then analyzes the source to identify code that could have run but did not. Nothing in that description mentions assertions, expected values, or boundary choices. The counter records execution; the quality of the check that triggered it lives somewhere else.

The counter is also older than most of the frameworks built around it. Martin Fowler published his test coverage bliki on 17 April 2012, and the distinction he drew then has survived largely intact: coverage helps find parts of a codebase that went untested, while saying very little, numerically, about how good the tests are. A team that reads a percentage as a verdict is asking the number to answer a question it was never designed for.

Four counters, four different questions

The confusion starts with the word coverage being used for measurements that count different things. The table below keeps the units separate.

Tool or standardCounting unitWhat one covered unit means
JaCoCo Linessource line, requires debug information in the class fileat least one instruction assigned to that line executed
JaCoCo Instructions (C0)individual Java bytecode instructionsmallest unit, independent of source formatting
coverage.py defaultstatement, also called line coveragethat statement executed; branch coverage is opt-in
Istanbul Statementsstatement, one of four reported itemscounted separately from branches, functions and lines
Istanbul Branchesbranch, from the official example18 of 24 branches, or 75 percent, while lines read 100 percent
Marick multiple-conditiontrue and false of each logical conditionboth outcomes appeared across runs, not necessarily in one run

JaCoCo's own wording is unusually blunt. A source line is considered executed when at least one instruction assigned to it has been executed. That single sentence explains why a line containing a compound condition can be marked covered when only part of the condition was exercised. The same manual lists branches (C1, aimed at if and switch, with exception handling excluded), cyclomatic complexity (v(G) = E − N + 2, equivalently v(G) = B − D + 1), methods — constructors and static initializers included — and classes. It also warns that compiler-generated synthetic code can produce unexpected results, and that a single source line may map to more than one method or class, so line counts do not simply add up.

Istanbul's reporters make the same point from the other direction. The documentation's text-summary shows Statements 100 percent (166/166), Branches 75 percent (18/24), Functions 100 percent (49/49) and Lines 100 percent (161/161) in one report. Four numbers, one codebase, four different answers. Quoting only the lines figure and calling it the coverage discards the other three.

The numbers teams reach for

Fowler expected carefully written tests to land in the upper 80s or 90s, and treated a figure below half as a signal that something was wrong. He also said anything near 100 percent would make him suspicious — in his experience it often means tests were written to make the number look good, even though the number itself is attainable. The same article carries Brian Marick's line about expecting high coverage, noting that managers sometimes require it, and observing that there is a subtle difference between the two. Marick's original PDF could not be opened in the environment behind this research; the wording here comes through Fowler's article, not from a page-by-page check of the source.

Google's 2020 engineering post is more explicit about the ceiling. Coverage guarantees that a line or branch was executed, not that it was tested correctly, and there is no ideal number that applies to every product. The three authors also call it an open research question whether coverage alone reduces defects. The often-quoted 60 percent acceptable, 75 percent commendable, 90 percent exemplary scale was an internal, non-mandatory guide, weighted by business criticality and change frequency, with an explicit preference against broad top-down mandates. The gain from pushing coverage higher, the post adds, is logarithmic past a certain point.

That last claim is worth holding onto. A team moving from a sparse suite to a basic one gets a real benefit; a team arguing about the difference between 91 and 94 percent is often polishing a number. The post points toward mutation testing as a better way to judge whether assertions hold, which is a different question with a different cost.

What the 2014 study actually measured

The strongest empirical objection came at ICSE in 2014. Laura Inozemtseva and Reid Holmes generated 31,000 test suites across five Java systems, the largest of which held 724,000 lines of source. They measured statement coverage, decision coverage and modified condition coverage, then used mutation testing to estimate how many defects each suite caught. Once the number of test cases was controlled for, coverage and effectiveness shared only a low-to-moderate correlation, and stronger coverage criteria did not buy noticeably more insight. The paper's conclusion is careful: coverage is useful for identifying under-tested parts of a program and should not be used as a quality target, because it is a poor indicator of suite effectiveness.

The sample matters. Five open-source Java systems are not mini-programs, and the result is a correlation on a specific corpus, not a law about software in general. Nothing in that study supports a claim that raising coverage by a given amount lowers production defects by a given amount — Google's post calls that relationship an open question. What the study does support is the narrower habit of using the number to find gaps, then reading the assertions.

Reading the percentage honestly

A practical reading starts by naming the counter. Line coverage from one tool, branch coverage from another and modified-condition coverage from a paper are not three spellings of the same figure. A hundred percent line coverage can coexist with untested branches, untested boundaries and expectations copied straight from the implementation. Fowler's suspicion of round numbers and Google's logarithmic-returns warning point at the same failure mode: once the number becomes the target, the cheapest way to move it is to write tests that execute code without checking it.

The honest use is less glamorous. Let the metric point at untouched paths, then read the code and decide whether the path deserves a test. Accept that two tools will disagree because they count different units. Keep the internal thresholds a team sets separate from the industry-wide standards that do not exist. And when a percentage rises, ask what changed in the assertions rather than assuming quality followed.

Where the shared runtime fits

Coverage is measured where code runs, and the unit of measurement is local to a build. A shared runtime and an open catalog change the geometry of that work without changing what the percentage means. One verified behavior can be carried to several host surfaces, so the gap-finding pass happens against a common core instead of being repeated per surface — a mechanism, not a measured saving, and no mini-program-specific coverage figure is claimed here. That is the modest part Cross Mini App plays: giving a number gathered in one place somewhere else to matter, while leaving its meaning exactly as narrow as the manuals say.

Sources