Decompose Run-On Tests
Kent Beck · email · 2026-10-13 Reader 🖥️
Tests that chain several operations and assertions into one body (run-on tests) are a natural by-product of exploratory coding but leave failures undiagnosable, so you should mechanically split them into short, descriptively named tests that each fail for one reason, trusting the suite as a whole to preserve the coverage.
practical · mixed — A craft how-to: a short diagnostic claim (run-on tests make failures un-diagnosable), an origin story (exploratory coding grows tests by accretion), then a four-step mechanical conversion recipe and a closing observation about trusting the suite as a whole. Propositions serve 'you should do X' (decompose them), with the recipe as the argument's payload.
Structure
| Part | Role |
|---|---|
| Opening definition and the student's example: a run-on test is set-up followed by repeated operation/assert pairs, borrowed from the grammatical run-on sentence (two parts that could each stand alone). | Names the pattern and gives the concrete shape the rest of the post operates on. |
| Diagnosis: a failing run-on does not tell you what is wrong, because a late assertion could fail from the preceding operation or from an earlier one that left the world in a bad state (violates the 'specific' property of Test Desiderata). | Establishes the cost that justifies the whole intervention. |
| Etiology: run-ons come from discovery-mode coding, where each revelation appends the next bit of testing to the largest existing test; algebra-shaped designs (composable things and operations) do not produce them; accretion explains power-law test-size distributions. Discovery is fine, leaving the relics is not. | Explains why the problem is predictable and assigns moral responsibility for cleaning it up. |
| Conversion recipe (4 steps): copy the test and truncate after assertion 1 and name it for what could go wrong; copy again, drop assertion 1 and everything after assertion 2, prune irrelevant set-up; repeat to the last assertion, noting newly visible paths for later; delete the original. | The operational core: a behavior-preserving, mechanical transformation. |
| Naming excerpt (Bad / Better / Best) and argument that test names may be long because they are typed once, never called, and read only in a failure report. | Sub-argument that the test name is the primary diagnostic interface at the moment of failure. |
| Final observation: the decomposed suite has the same coverage only if you commit to running the tests together and keeping them all green; later tests can omit earlier assertions because another test will break; trusting the suite as a whole is what enables simplification (the 'composable' desideratum). | Names the hidden precondition that makes the deletion of assertions safe. |
Key terms
- run-on test
A test with a set-up followed by multiple operation/assert pairs, any prefix of which could stand alone as a complete test; coined during the writing of this post by analogy with the run-on sentence. - specific (Test Desiderata property)
A test property: when it fails, the cause is evident from the failure. Run-ons violate it because the failing step is ambiguous. - composable (Test Desiderata property)
The property that a suite's tests can be understood and combined as a whole, so any one test may rely on others to catch what it leaves out; here it licenses deleting earlier assertions from later tests. - discovery mode
Coding without a known design: exploring by doing the next small thing as each insight arrives ('I'd like an object like this... oh, it needs an operation like that'), making progress in a dark room without breaking anything. - relics of past ignorance
Artifacts left behind by exploration (here run-on tests) that were reasonable when written but now cost colleagues time. - algebra (design as)
A design that presents itself as things plus operations that compose; such designs lead to tests and code written in small pieces. - largest existing test (as natural place for next test)
The attractor in accretive test growth: when every step is a revelation, the next bit of testing goes into whichever test is already biggest, yielding power-law size distributions. - decompose
A copy-truncate-prune-delete procedure that turns one run-on into N prefix tests, preserving coverage while restoring specificity.
Propositions
- explicitA run-on test is one that strings a set-up and several operation/assert pairs together, so that any prefix could itself be a complete test.conf: high
- explicitWhen a run-on test fails you cannot tell what is wrong: a later assertion could be failing because of the immediately preceding operation or because an earlier operation left the world in a bad state, which turns the failure into a debugging problem.conf: high
- explicitRun-on tests arise from coding in discovery mode: each new insight adds the next bit of testing to the largest existing test, so tests grow by accretion rather than by design.conf: highextendsKent Beck's Post · p4 — Beck's TDD loop interleaves learning with specification; this post names the residue that learning leaves behind (tests that grew by accretion) and says it needs a separate consolidation step.
- explicitWhen a design presents itself as an algebra (things and operations that compose), tests and code get written in little pieces and run-on tests do not appear; test shape is therefore feedback about how well the design is understood.conf: mediumsupportsPractices I Abandoned with Agents: An Ode to Test-Driven Development · p2 — Both treat tests as design feedback, not just verification: the shape of the tests (little pieces vs. run-ons) reflects how well the design is understood.
- explicitAccretion toward the largest existing test explains the power-law distribution of test sizes seen in test suites.conf: medium
- explicitCoding in discovery mode is legitimate and valuable, but leaving its artifacts (relics of past ignorance) for colleagues to trip over is not acceptable; cleanup is owed to others.conf: high
- explicitA run-on can be converted mechanically and safely: copy the test, keep only up to the first assertion, then repeat for each subsequent assertion while pruning set-up and operations the assertion doesn't need, then delete the original.conf: high
- explicitA test's name should be chosen for the reader of a failure report: the failing-test line is the only context at that moment, so the name should say what could have gone wrong and point at where to look.conf: high
- explicitTest names are allowed to be much longer and more explanatory than function names because they are typed once, never formatted into calling code, and read only in a failure context.conf: high
- explicitOnce tests are short and named after what could go wrong, explanatory messages in assertions are redundant and can be omitted.conf: high
- explicitDecomposition preserves exactly the original coverage only if the team commits to running the tests together and keeping them all passing; coverage is a property of the suite, not of any single test.conf: high
- explicitDeleting earlier assertions from later tests is safe because if something earlier goes wrong another test will break; learning to trust the suite as a whole is what lets you simplify individual tests (the 'composable' property).conf: high
- explicitWhile decomposing, new paths that deserve coverage (for example a different operation order) should be noted and written after the decomposition is finished, not mixed into it.conf: high
- implicitThe main value of a test at the moment it matters (when it fails) is communication and diagnosis to a future reader, not merely detection that something broke.conf: high
- implicitThe cost of a badly shaped test is externalized: it is paid later by someone else (a colleague or future self) at failure time, which makes test hygiene a professional obligation rather than a personal preference.conf: high
- implicitRun-on tests are a structural tendency of exploratory work, not a personal failing ('natural' in the sense of natural law), so cleaning them up has to be a deliberate separate step rather than something good intentions will prevent.conf: medium
- implicitRestructuring tests is a behavior-preserving move that should be kept separate from adding new behavior or coverage: tidy the structure first, then add the tests that the tidying revealed.conf: medium
- implicitShort, cheap-to-set-up tests are the normal case, so duplicating set-up across the decomposed tests is an acceptable price (or can be extracted to setUp) for the gain in specificity.conf: medium
Arguments
Run-on tests should be decomposed into several short tests. strength: high
Explicit premises:
- A failing run-on does not tell you which operation is at fault, especially for late assertions.
- That ambiguity violates the 'specific' property of good tests.
- Decomposition yields a suite with exactly the same coverage as the original.
Implicit premises:
- Diagnosing a failure by reading test-runner output is the dominant way tests are used; stepping through in a debugger is the expensive fallback.
- Set-up is cheap enough that repeating it across tests costs little.
- Specificity is worth more than whatever is lost by splitting (shared-state continuity, fewer test objects).
- The whole suite is always run together, in a deterministic order-independent way.
Inferences:
- Test shape is a smell indicator for design clarity: big multi-assertion tests suggest the design was found rather than understood.
- The same transformation could be applied automatically (a mechanical refactoring tool, or an agent), since it requires no judgment other than names.
Run-on tests are a predictable by-product of exploration and must be cleaned up afterwards rather than prevented by never exploring. strength: medium
Explicit premises:
- In discovery mode each step is a revelation, so the next bit of testing naturally goes in the largest existing test.
- Discovery-mode coding is a useful skill (progress in the dark without breaking things).
- Leaving the relics around hurts colleagues.
Implicit premises:
- Adding to an existing test is locally cheaper than creating a new test with its own name and set-up, so accretion is the path of least resistance.
- The person who discovered is the one best placed to clean up, and the time to do so is after the design has settled.
- Design algebra can only be recognized after exploration, not before.
Inferences:
- Test-size distributions are a cheap, observable proxy for where a team explored and did not clean up.
- The cleanup obligation scales with how far the code outlives the explorer's memory.
It is safe to delete earlier assertions from the later tests when decomposing. strength: high
Explicit premises:
- Each earlier assertion survives in its own shorter test.
- If an earlier state is wrong, that test will break.
- The team commits to running all tests together and keeping them working.
Implicit premises:
- Every operation prefix is deterministic, so a later test's state matches what the earlier test asserted.
- Test selection (sharding, partial runs, quarantined flaky tests) does not routinely drop the 'earlier' test while keeping the later one.
- A failure appearing in several tests at once is tolerable because the shortest failing test points at the root cause.
Inferences:
- Test-suite integrity (never skipping or silently disabling tests) is a precondition of this style of test design.
- When a test is weakened or deleted (by a human or an agent), the guarantee for every test that relied on it quietly disappears.
Tests should have long, descriptive names that say what could go wrong. strength: high
Explicit premises:
- At failure time the only context the reader has is the test name in the runner output.
- Test names are typed once and never formatted in calling code, so length costs almost nothing.
Implicit premises:
- The failure report is the reader's entry point and most readers don't open the test body first.
- A name can compress a failure hypothesis (consistent names and experiments) accurately enough to localize the problem.
- Name and assertion content stay in sync over time.
Inferences:
- A hard-to-name test is a signal that it does too much.
- Name drift is the failure mode: a stale long name is worse than a short vague one because it points readers the wrong way.
Narratives
- A student brings Beck a test shaped set-up / assert / operation / assert / operation / assert...; Beck realizes he has written the same thing himself and gives it the name 'run-on test'.
→ Grounds the pattern in a real, ordinary case and signals that the author is no outsider to the problem, which supports the 'natural by-product of exploration' claim. - Beck's own exploring monologue: 'I'd like an object like this.' Done. 'Oh, I see, it needs an operation like that.' Done. 'But that means it could have another operation like this.' Done.
→ Shows concretely how accretion into one test happens step by step, supporting the claim that run-ons are produced by discovery mode. - The run-on sentence analogy from a grammar guide: a sentence with at least two parts, either of which could stand alone.
→ Imports an everyday editing norm (split a run-on sentence) to justify the testing norm, and defines the pattern's detection rule. - The naming ladder: testInitialization (bad), initializationProducesConsistentExperiments (better), initializationProducesConsistentNamesAndExperiments (best).
→ Worked example of 'name for the reader of the failure', showing how each rewrite narrows where to look. - Beck notes that the idea of keeping the whole suite running together took him a while to get and often surprises students.
→ Marks the closing premise (coverage lives in the suite) as non-obvious and learned from experience, not self-evident.
Questions addressed
- ✅ Why do test suites accumulate huge, multi-purpose tests that are hard to debug?
Because discovery-mode coding appends the next bit of testing to the largest existing test, producing run-ons and power-law test sizes. - ✅ What do I do with a run-on test I already have?
Apply the four-step copy/truncate/prune/delete recipe, naming each resulting test for what could go wrong. - ✅ How can I split a test without losing coverage?
Coverage is preserved by the suite as a whole as long as you run all tests together and keep them passing. - ⭕ When should a run-on be decomposed relative to the exploration that produced it, and what triggers it?
Beck says exploring is fine and leaving relics is not, but does not say whether to clean up per insight, at design settling, or at review time. - ⭕ What if set-up is expensive, or the sequence itself is what is under test?
Not addressed; the recipe assumes prefixes are cheap to rebuild.
Gaps
- incompleteThe recipe assumes repeating set-up and operation prefixes is cheap. For integration tests, slow fixtures, databases or UI flows, N prefix-tests cost O(N^2) operations, and some workflows genuinely are sequences (stateful protocol, wizard, lifecycle) where the chain is the behavior. The post never says where run-on is acceptable or how to trade specificity against speed and isolation (other Desiderata properties).
Read next: Kent Beck's Test Desiderata (isolated, fast, structure-insensitive, specific, composable) and the tradeoffs among them; Meszaros's xUnit Test Patterns on Eager Test / Assertion Roulette and Chained Tests. - incomplete'Exactly the same coverage' is never defined: statement coverage is preserved by construction, but fault-detection power depends on the suite being run whole and in a stable state, and on every dropped assertion having a surviving twin. Nothing checks that equivalence (e.g. by mutation testing) and the post is silent on what happens when tests are selectively run, sharded, quarantined or flaky.
Read next: Mutation testing as a check on test-suite equivalence; DORA/CI practice on partial test runs; the corpus's 'validating the validators' gap in extract-tornhill-practices-abandoned-with-agents-tdd#g1. - incompleteThe justification is a human debugger reading a failure report. With coding agents, run-ons are generated at scale by the same accretion dynamics (agent appends to the nearest test), agents can decompose them mechanically in seconds, and agents also weaken or delete tests whose assertions inconvenience them, which attacks the 'another test will break' safety premise. The post does not consider whether specificity matters differently when the failure reader is a model.
Read next: Beck's recent AI-era Tidy First? pieces (e.g. 'Starving Genies'); Tornhill on practices abandoned with agents; Osmani on agents satisfying the literal assertion. - uninformedThe claims that accretion explains power-law distributions of test sizes, and that run-ons commonly come from discovery mode rather than from, say, expensive set-up or haste, are offered as plausible explanations with no data or survey of real suites.
Read next: Empirical studies of test-suite structure and test smells (e.g. work on assertion roulette / eager test prevalence). - incompleteTiming and ownership of the cleanup is left open: Beck wants relics gone, yet discovery mode is explicitly licensed and the decomposition is described as a separate session from the exploring. When in the TDD/refactor rhythm to decompose, and who pays (discoverer vs. whoever hits the failure), is not argued, which is exactly the 'tidy first, after, or never' decision that Beck's Tidy First? series addresses elsewhere.
Read next: Kent Beck, Tidy First? (when to tidy: first, after, later, never); Fowler on refactoring cadence.
Related documents
- Practices I Abandoned with Agents: An Ode to Test-Driven Development
- It Ain't Broke: Why Software Fundamentals Matter More Than Ever
- Why Rust is different, with Alice Ryhl
- [FULL WORKSHOP] AI Coding For Real Engineers - Matt Pocock, AI Hero
- Maintainability sensors for coding agents
- Jimmy Nilsson's Post — reflections after the Thoughtworks 'Future of Software Development' retreat
- Software Design in the Agentic Age: Place Your Bets
- 11 Tips For AI Coding With Ralph Wiggum
- 5 Things World-Class Engineers Do That You Don't
- Addy Osmani's Post