Decompose Run-On Tests

Kent Beck · email · 2026-10-13 Reader 🖥️

Agile & XPCode QualityFeedback LoopsSoftware Design FundamentalsTest-Driven Development
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

PartRole
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

Propositions

Arguments

Run-on tests should be decomposed into several short tests. strength: high
Explicit premises:
Implicit premises:
Inferences:
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:
Implicit premises:
Inferences:
It is safe to delete earlier assertions from the later tests when decomposing. strength: high
Explicit premises:
Implicit premises:
Inferences:
Tests should have long, descriptive names that say what could go wrong. strength: high
Explicit premises:
Implicit premises:
Inferences:

Narratives

Questions addressed

Gaps

Related documents