Case file TS1

Living Documentation

Tests don't lie.

Prose lies. Tests fail. The test file is the spec because the spec is the thing that goes red when the code changes. Nothing else in the repository has that property.

ByAdam LewisPublished3 May 2026Revised23 Oct 2026Reading12 minVersionv1.2ConfidenceHigh
§0b

Opinion

I have read enough README files lying about the API beneath them to stop trusting prose altogether. The doc says POST /orders accepts an idempotency key; the handler has not since the rewrite three sprints ago. The doc says this method returns null on miss; it throws. The doc was right when it was written and wrong by the next commit and the next reader either trusts it and merges a bug, or distrusts every doc on the way past. The same instinct that drives F5 Self-Documenting Code (let the artefact hold the meaning) is what TS1 is on the testing surface.

The test in CI cannot drift. It either passes or it fails and a green build is the single thing in the codebase that says this is still true today. Gojko Adzic named this the seventh of his seven Specification by Example patterns: evolving a documentation system, with living documentation as the exhaust of an SBE engine.1 Cyrille Martraire's 2019 book widens it past Gherkin: living glossaries, code-derived diagrams, runtime documentation, every artefact that updates because it has to or breaks because it must.2 Same idea on different surfaces.

The practical consequence is what a working developer feels first: stop writing the README first and the tests later. Write the tests. Let the README be a paragraph that points at the test file and the Gherkin folder. The reader who needs the truth runs the suite. The reader who needs the gist reads the test names. Neither reader is reading prose written six months ago by somebody who has since left.

Copy a note and link

Grab this short comment and drop it into a PR comment or an LLM chat to prompt the right change.

Tests don't lie. The test file is the most reliable description of behaviour you have: prose drifts, scenarios fail. If a behaviour matters, prove it with a test. If a doc explains what a test would have caught, replace the doc with the test.

/tenet/living-documentation/TS1
Copy for paste
§0c

AI eyes only

Rule: tests are the spec. Test names read as full sentences describing one behaviour.

Reject: test names like handlesEdgeCase, worksCorrectly, test1. Reject: prose docs that re-explain what the tests already prove.

Generate: test names that read as sentences ( rejects an order whose total is negative). Each test isolates one behaviour the spec calls out. The test list is the behavioural index of the unit.

Diagnostic: read the test names aloud as a list. They must read as the behavioural spec of the unit, with no help from the implementation.

§0d

Why?

  • Documentation that fails when it lies. The build is red until the prose and the behaviour agree, so the next reader sees the truth or sees a broken pipeline.
  • The spec lives where the code lives. The test file sits in the same PR as the change it describes, so the diff carries both the behaviour and the assertion of the behaviour.
  • Reviewers read the test names first. A directory of spec files reads as a feature list. A directory of READMEs reads as historical fiction.
  • Same operating principle as F5 Self-Documenting Code on the testing surface. The artefact holds the meaning, not the prose beside it.
  • Coding agents read the test as a specification they can satisfy. A green run is the one thing in the repo that says “this is still true today,” and the model treats it as such.
  • Pair with TS2 Specification by Example when the reader is a stakeholder. The same scenario doubles as feature documentation and acceptance check.
  • Cuts the class of bugs caused by stale prose, the README that lies about the API, the comment that describes the previous behaviour, the wiki page nobody updated after the rewrite.
The receipts
Origins, quoted passages, evidence, the strongest counter-argument and the reply.
§1

Origins

The phrase living documentation enters the working vocabulary through Gojko Adzic and the Specification by Example community. Adzic's 2011 book names “evolving a documentation system” as the seventh of his seven SBE process patterns, with living documentation as its output: the exhaust of an engine in which automated examples are written, refined, and kept in human-readable form alongside the code they describe.1 The term is downstream of Dan North's 2006 introduction of BDD, where Given/When/Then was already proposed as a template for acceptance criteria structured enough to automate.8

Cyrille Martraire's Living Documentation (2019) is the first dedicated book on the term and it widens the scope past BDD scenarios into a 15-chapter taxonomy: living glossaries, runtime documentation, refactorable architecture diagrams, code-derived explanations, generated context maps.2 Behaviour-driven scenarios are one chapter inside that book. The rule is bigger. Anything that is authoritative and co-located with the artefact it describes counts. The test file is the canonical instance because it has the second property by construction.

Kent Beck's Test Desiderata names the property as Predictive: if the tests all pass, the code under test should be suitable for production.9 Gerard Meszaros's xUnit Test Patterns catalogues the same property under Tests as Documentation, and presents the inverse smell: Obscure Test, as the failure mode that erodes it.10 The doctrine is not new. The testing form hurts because tests are the only artefact whose drift is announced by a build failure.

The standard the principle most directly displaces is the comment that explains a method. F5 Self-Documenting Code is the foundations-side rule: improve the name and refactor instead of annotating. TS1 is the testing-side rule: write the test instead of the paragraph. The two tenets are one operating principle on different surfaces: the artefact holds the meaning, not the prose beside it.

§2

Quotes

An automated specification with examples, still in a human-readable form and easily accessible to all team members, becomes an executable specification.

Gojko Adzic · Specification by Example (2011)

You will see that you don't necessarily have to choose between working software and extensive documentation!

Cyrille Martraire · Living Documentation (2019)

The code reflects the documentation and the documentation reflects the team’s shared understanding of the problem domain.

Cucumber Docs · BDD Overview

Predictive — if the tests all pass, then the code under test should be suitable for production.

Kent Beck · Test Desiderata (2019)
§3

Evidence

18 external sources, ranked by author authority. The first five are the canon; expand to see the rest, including the qualifiers and the named opposers. Each links out to its primary source.

  1. 01
    Gojko Adzic · 2011
    The first verbatim use of “living documentation” as the named outcome of automated examples. Pattern #7 of seven: keep the executable specification human-readable and co-located with the code.
  2. 02
    Cyrille Martraire · 2019
    The only book-length treatment of the subject. Widens the scope past Gherkin into glossaries, runtime documentation, refactorable diagrams, code-derived prose. BDD scenarios are one chapter inside a 15-chapter taxonomy.
  3. 03
    BDD OverviewSupports
    Cucumber documentation · 2020+
    “The code reflects the documentation, and the documentation reflects the team’s shared understanding.” The canonical Cucumber idea of the property TS1 names.
  4. 04
    Kent Beck · 2003
    The foundational instinct: tests as runnable specifications. Read together with the “Predictive” entry in Beck’s later Test Desiderata for the property TS1 abstracts.
  5. 05
    Kent Beck · 2019
    Names the property as Predictive: if the tests all pass, the code under test should be suitable for production. The truth-axis claim TS1 leans on.
  1. 06
    Gerard Meszaros · 2007
    Catalogues the property under “Tests as Documentation”. Identifies the inverse smell “Obscure Test” as the failure mode that erodes it. The reference text on test-as-spec mechanics.
  2. 07
    Dan North · 2006
    The article that named the practice. Given/When/Then proposed as a template for acceptance criteria, loose enough for analysts and structured enough to automate.
  3. 08
    What is BDD?Supports
    Liz Keogh · 2015
    “Using examples in conversation to illustrate behaviour.” The most-cited modern compression. The anchor is conversation: she still calls it BDD when the examples cannot be automated.
  4. 09
    Adam Bender · 2020
    FAANG-scale evidence: the test is the load-bearing description of behaviour at Google. Tests as the only documentation that is forced to be honest by the build.
  5. 10
    Lisa Crispin & Janet Gregory · 2009
    Q2 (business-facing tests that support the team) are the explicit place living documentation belongs in the testing-quadrant taxonomy. The agile-testing canon’s home for the principle.
  6. 11
    Robert C. Martin · 2008
    Argues test code is just as important as production code and must be kept as clean. The clearest mainstream restatement of the form-axis claim.
  7. 12
    BDD HistorySupports
    Cucumber documentation · 2020+
    Traces the lineage from Evans’s Domain-Driven Design (ubiquitous language) through North’s BDD into the Cucumber-era spec-as-doc convention. The pedigree TS1 inherits.
  8. 13
    Daniele Procida · 2017+
    Splits documentation into tutorials, how-tos, references, explanations. Tests primarily produce one (reference). The honest qualifier: TS1 covers one of four modes well, not all four.
  9. 14
    Michael Bolton · 2009
    Sets out the distinction: checking confirms existing beliefs, testing looks for new information. A test treated as the spec rots into a regression net that stops asking new questions.
  10. 15
    Cem Kaner, James Bach & Bret Pettichord · 2002
    Predates the checking-vs-testing distinction, which co-author James Bach later refined with Michael Bolton. The qualifier the reply has to address: regression as documentation only covers what you already thought to test for.
  11. 16
    David Thomas & Andrew Hunt · 1999, 2019
    Tracer Code as the executable knowledge artefact. Code generators as living documentation by another name. The longest-running mainstream support for the property.
  12. 17
    Hillel Wayne · 2021
    Argues self-documentation is impossible because the writer brings invisible context the reader lacks. Extended to TS1: the test alone cannot encode the why. The spec without prose loses information.
  13. 18
    J. B. Rainsberger · 2009
    Argues against integrated tests, not against tests as the spec: nobody can write enough of them to cover the code paths, and each one added deepens a false sense of security. A green build documents only the paths its tests reach.

Eighteen sources, three stances. The supports are the canon: Adzic, Martraire, Cucumber, and Beck. The qualifiers further down carve out the part of documentation tests cannot carry: conceptual explanation, exploratory questioning. The opposer sharpens the steelman the reply has to address.

§4

Examples

Viewing: TypeScript.
Avoid
Filesanctuary-census.ts
// Returns the count of hedgehogs in the sanctuary.
export function countActiveHedgehogs(sanctuary: Sanctuary): number {
  return sanctuary.intake.filter((h) => h.status !== "released").length;
}
Prefer

After no comment to lie. The test name is the specification.

Filesanctuary-census.spec.ts
export function countActiveHedgehogs(sanctuary: Sanctuary): number {
  return sanctuary.intake.filter((h) => h.status !== "released").length;
}

it("excludes released hedgehogs from the active count", () => {
  const sanctuary: Sanctuary = { intake: [
    { name: "boris", status: "resident" },
    { name: "prickles", status: "released" },
    { name: "spike", status: "recovering" },
  ] };
  expect(countActiveHedgehogs(sanctuary)).toBe(2);
});
§4b

Enforcement

Viewing: TypeScript.

Apply these rules in eslint.config.mjs. The full enforcement across every tenet lives on the implementation page.

RuleToolCatches
vitest/valid-title@vitest/eslint-pluginempty, non-string, duplicate-prefixed or space-padded titles. Add disallowedWords or mustNotMatch to ban “should” and other fragments.
vitest/no-disabled-tests@vitest/eslint-plugin“.skip” or “xit” calls left in main. A disabled test is documentation that lies; the suite says behaviour is asserted when it isn’t.
vitest/no-focused-tests@vitest/eslint-plugin“.only” left in committed tests. Same failure mode as a skip: the suite reports green but most of it never ran.
vitest/expect-expect@vitest/eslint-plugintests with no assertion. A test that asserts nothing is a sentence with no verb: it can’t be documentation.
vitest/no-identical-title@vitest/eslint-pluginduplicate test names. The suite output is a feature list; duplicate entries make it useless as documentation.
vitest/prefer-each@vitest/eslint-pluginloops of duplicated it() blocks. it.each turns each row into its own line in the reporter, which reads as documentation.
vitest --reporter=verboseVitestmissing test-level visibility. The verbose reporter prints every describe/it name: the artefact you point reviewers at as the spec.
eslint.config.mjsconfiguration snippet
import vitest from '@vitest/eslint-plugin';

export default [
  {
    files: ['**/*.{spec,test}.{ts,tsx}'],
    plugins: { vitest },
    rules: {
      'vitest/valid-title': ['error', { ignoreTypeOfDescribeName: false }],
      'vitest/valid-describe-callback': 'error',
      'vitest/no-disabled-tests': 'error',
      'vitest/no-focused-tests': 'error',
      'vitest/no-identical-title': 'error',
      'vitest/expect-expect': 'error',
      'vitest/no-conditional-tests': 'error',
      'vitest/prefer-each': 'error',
      'vitest/padding-around-describe-blocks': 'error',
      'vitest/padding-around-test-blocks': 'error',
    },
  },
];
§4c

AI rules

File.cursor/rules/ts1-living-documentation.mdc
---
alwaysApply: true
---

## Prickles TS1: Living Documentation

If a behaviour matters, write a test that proves it. The test is the spec. Prose docs are a paraphrase.

When the code changes, the test fails or it doesn't. Prose can drift in silence. A test in CI cannot. The first signal is a red build, not a stale paragraph.

Name the test after the behaviour rather than the method. `it('rejects an order whose total is negative')` reads as a sentence; `it('throws on negative total')` reads as a regex.

Where stakeholders read the spec, write Gherkin. Where developers read the spec, write Vitest. Both are living documentation. Neither is the comment that rotted.

Repo layout, CI, and ESLint wiring for these paths live on /implementation, not repeated on every tenet.

§5

Counter-argument

Counter

The honest steelman is Daniele Procida's.3 Diátaxis splits documentation into four kinds (tutorials, how-tos, references, explanations) and tests primarily produce one of them. The reference is automatable. The tutorial that walks a new hire through the system, the how-to that explains the migration play, the explanation that traces why the architecture decided one way and not the other: none of those is a test. Michael Bolton's split between testing and checking sharpens it from a different angle: treating the test file as the spec rots the test from asking questions into checking known answers and the suite becomes a regression net rather than a probe.4 A reader who needs the why has nowhere to go.

§6

Counter-argument retort

Reply

Procida is right that tests primarily produce one of his four documentation modes. The reply isn't to deny the other three. It's to reject the comment that pretends to carry them. A tutorial is its own artefact, written for new hires, kept in sync because somebody reads it on day one. A how-to is its own artefact, owned by the team that runs the migration. An explanation lives in an ADR, numbered, dated and superseded rather than edited.5 The class of prose TS1 displaces is the in-line comment about behaviour and the paragraph in the README that paraphrases an API: the prose that should have been a test and was written instead because the test was hard.

Michael Bolton's testing versus checking distinction4 is the strongest sharpening: an automated test that becomes a regression net stops asking new questions of the system. The reply concedes and adds two artefacts. First, property-based tests (QuickCheck, Hypothesis, fast-check) restore the questioning view by generating inputs the developer hasn't imagined.6 Second, exploratory testing kept on the team's books as a separate activity, not pretending to be regression. The living-documentation property survives both: properties fail loudly when reality drifts. Exploratory notes are dated and short-lived by design.

Hillel Wayne's objection7 (that code and tests can only encode certain classes of information, and that negative information, optimisation notes and tips need prose) is conceded inside its scope and refused outside it. What the code deliberately does not do belongs in prose: an ADR, a commit message. What the code does belongs in a test: a Vitest file or a Gherkin scenario holds more truth than the README ever did. The honest residue is published-API surface where the contract is irreducibly prose: cite the OpenAPI, the JSDoc tag, the typed signature, see T1 Domain-Driven Types. Even there, the living-documentation property is the property the artefact has to earn. If the OpenAPI lies, the contract test catches it.

In production code the doc that explains is the doc that lies. The next reader trusts the doc, the doc is wrong and a bug goes out. Write the test: the test is the spec, the spec is the doc, the doc is in CI. The discipline is the same one F5 enforces on the comment surface; TS1 is its testing-side corollary.

§7

Notes

  1. [1]Gojko Adzic: Specification by Example: How Successful Teams Deliver the Right Software (Manning, 2011). Pattern #7 of the seven SBE process patterns: “Evolving a documentation system,” whose output is living documentation. The earliest verbatim use of the term as a named outcome of automated examples.
  2. [2]Cyrille Martraire: Living Documentation: Continuous Knowledge Sharing by Design (Addison-Wesley, 2019). The first standalone book on the subject. Widens it past Gherkin into a 15-chapter taxonomy of techniques whose property is co-located, evolving, machine-checkable.
  3. [3]Daniele Procida: Diátaxis (diataxis.fr, 2017+). Splits documentation into tutorials, how-tos, references and explanations. The honest steelman: tests primarily produce one (reference), not all four.
Disagree? Found a hole in the argument? Take issue with this tenet →
Last revised: 2026-10-23