Code Coverage
The proportion of code executed by a test suite — a map of what is untested, not a measure of quality.
Code coverage is the fraction of a codebase executed while the tests run, reported per statement, per line, per function, and per branch. It is produced by Instrumentation.
What it can tell you is narrow and genuinely useful: which code no test has ever run. Uncovered code is untested by definition. That is worth knowing.
What it cannot tell you is whether the covered code is correct. A test that executes a function and asserts nothing produces identical coverage to one that specifies it exactly. This is why coverage makes such a poor target — see Goodhart's Law and Coverage Gate.
Two mechanical facts save a lot of confusion. A failing test yields no coverage number at all: the reporter aborts before writing its summary, so an unrelated red test produces an absent measurement, not a threshold failure. And percentages are the wrong unit for diagnosis; the underlying per-position records are what actually explain a shortfall, and a report format that emits them is usually one flag away.
Coverage also behaves oddly across multiple test environments measuring the same files, where a single logical position can end up recorded twice; see Branch Coverage.
See also7
Branch Coverage
The proportion of conditional outcomes exercised — the strictest ordinary coverage metric, and the most informative.
Testing & Verification12 connections
Coverage Gate
A build check that fails when coverage falls below a threshold, and what that pressure produces.
Testing & Verification16 connections
Unreachable Code
Code no input can execute — usually a guard against a state the surrounding invariants forbid.
Testing & Verification10 connections
Instrumentation
Adding measurement to code so its execution can be observed, and the distortions that introduces.
Testing & Verification17 connections
Module Graph
The directed graph of imports that decides what code ends up where.
Web Platform20 connections
Regression
A previously working behavior that a change has broken.
Method19 connections
Test-Driven Development
Writing a failing test first, making it pass, then improving the code with the test as a net.
Testing & Verification10 connections
Related2
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from13
- Branch CoverageTesting & Verification
The proportion of conditional outcomes exercised — the strictest ordinary coverage metric, and the most informative.
- Coverage GateTesting & Verification
A build check that fails when coverage falls below a threshold, and what that pressure produces.
- Goodhart's LawMethod
When a measure becomes a target, it stops being a good measure.
- InstrumentationTesting & Verification
Adding measurement to code so its execution can be observed, and the distortions that introduces.
- Integration TestTesting & Verification
A test exercising several components together, through real interfaces rather than doubles.
- InterpreterComputation & Algorithms
A program that executes source code directly, statement by statement, without a separate translation step first.
- Module GraphWeb Platform
The directed graph of imports that decides what code ends up where.
- Mutation TestingTesting & Verification
A test-of-tests that injects small bugs into code and checks whether the existing suite catches them, exposing tests that assert nothing.
- RegressionMethod
A previously working behavior that a change has broken.
- Test-Driven DevelopmentTesting & Verification
Writing a failing test first, making it pass, then improving the code with the test as a net.
- Tree ShakingWeb Platform
Statically removing exports that nothing imports, shrinking the shipped bundle.
- Unit TestTesting & Verification
A fast, isolated test of one unit of behavior with its collaborators replaced.
- Unreachable CodeTesting & Verification
Code no input can execute — usually a guard against a state the surrounding invariants forbid.