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.
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
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.
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
specfiles 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.
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.
Quotes
An automated specification with examples, still in a human-readable form and easily accessible to all team members, becomes an executable specification.
You will see that you don't necessarily have to choose between working software and extensive documentation!
The code reflects the documentation and the documentation reflects the team’s shared understanding of the problem domain.
Predictive — if the tests all pass, then the code under test should be suitable for production.
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.
- 01The 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.
- 02The 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.
- 03BDD OverviewSupports“The code reflects the documentation, and the documentation reflects the team’s shared understanding.” The canonical Cucumber idea of the property TS1 names.
- 04The foundational instinct: tests as runnable specifications. Read together with the “Predictive” entry in Beck’s later Test Desiderata for the property TS1 abstracts.
- 05Test Desiderata: PredictiveSupportsNames 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.
- 06Catalogues 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.
- 07Introducing BDDSupportsThe article that named the practice. Given/When/Then proposed as a template for acceptance criteria, loose enough for analysts and structured enough to automate.
- 08What is BDD?Supports“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.
- 09FAANG-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.
- 10Agile Testing: Q2 quadrant testsSupportsQ2 (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.
- 11Clean Code, ch. 9: Unit TestsSupportsArgues test code is just as important as production code and must be kept as clean. The clearest mainstream restatement of the form-axis claim.
- 12BDD HistorySupportsTraces 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.
- 13Splits 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.
- 14Testing vs. CheckingQualifiesSets 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.
- 15Lessons Learned in Software TestingQualifiesPredates 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.
- 16Tracer Code as the executable knowledge artefact. Code generators as living documentation by another name. The longest-running mainstream support for the property.
- 17Argues 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.
- 18Integrated Tests Are A ScamQualifiesArgues 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.
Examples
// Returns the count of hedgehogs in the sanctuary. export function countActiveHedgehogs(sanctuary: Sanctuary): number { return sanctuary.intake.filter((h) => h.status !== "released").length; }
After no comment to lie. The test name is the specification.
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); });
// Returns the count of hedgehogs in the sanctuary. export function countActiveHedgehogs(sanctuary: Sanctuary): number { return sanctuary.intake.filter((h) => h.status !== "released").length; }
After no comment to lie. The test name is the specification.
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); });
// Returns the count of hedgehogs in the sanctuary. export function countActiveHedgehogs(sanctuary) { return sanctuary.intake.filter((h) => h.status !== "released").length; }
After no comment to lie. The test name is the specification.
export function countActiveHedgehogs(sanctuary) { return sanctuary.intake.filter((h) => h.status !== "released").length; } it("excludes released hedgehogs from the active count", () => { const sanctuary = { intake: [ { name: "boris", status: "resident" }, { name: "prickles", status: "released" }, { name: "spike", status: "recovering" }, ] }; expect(countActiveHedgehogs(sanctuary)).toBe(2); });
# Returns the count of hedgehogs in the sanctuary. def count_active_hedgehogs(sanctuary: Sanctuary) -> int: return sum(1 for h in sanctuary.intake if h.status != "released")
After no comment to lie. The test name is the specification.
def count_active_hedgehogs(sanctuary: Sanctuary) -> int: return sum(1 for h in sanctuary.intake if h.status != "released") def test_excludes_released_hedgehogs_from_the_active_count() -> None: sanctuary = Sanctuary(intake=[ Hedgehog(name="boris", status="resident"), Hedgehog(name="prickles", status="released"), Hedgehog(name="spike", status="recovering"), ]) assert count_active_hedgehogs(sanctuary) == 2
// Returns the count of hedgehogs in the sanctuary. static int countActiveHedgehogs(Sanctuary sanctuary) { return (int) sanctuary.intake().stream() .filter(h -> !h.status().equals("released")) .count(); }
After no comment to lie. The test name is the specification.
static int countActiveHedgehogs(Sanctuary sanctuary) { ... } @Test void excludesReleasedHedgehogsFromTheActiveCount() { Sanctuary sanctuary = new Sanctuary(List.of( new Hedgehog("boris", "resident"), new Hedgehog("prickles", "released"), new Hedgehog("spike", "recovering") )); assertEquals(2, countActiveHedgehogs(sanctuary)); }
// Returns the count of hedgehogs in the sanctuary. function countActiveHedgehogs(Sanctuary $sanctuary): int { return count(array_filter($sanctuary->intake, fn($h) => $h->status !== "released")); }
After no comment to lie. The test name is the specification.
function countActiveHedgehogs(Sanctuary $sanctuary): int { ... } public function test_excludes_released_hedgehogs_from_the_active_count(): void { $sanctuary = new Sanctuary(intake: [ new Hedgehog(name: "boris", status: "resident"), new Hedgehog(name: "prickles", status: "released"), new Hedgehog(name: "spike", status: "recovering"), ]); $this->assertSame(2, countActiveHedgehogs($sanctuary)); }
Enforcement
Apply these rules in eslint.config.mjs. The full enforcement across every tenet lives on the implementation page.
| Rule | Tool | Catches |
|---|---|---|
| vitest/valid-title | @vitest/eslint-plugin | empty, 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-plugin | tests 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-plugin | duplicate test names. The suite output is a feature list; duplicate entries make it useless as documentation. |
| vitest/prefer-each | @vitest/eslint-plugin | loops of duplicated it() blocks. it.each turns each row into its own line in the reporter, which reads as documentation. |
| vitest --reporter=verbose | Vitest | missing 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',
},
},
];Apply these rules in eslint.config.mjs. The full enforcement across every tenet lives on the implementation page.
| Rule | Tool | Catches |
|---|---|---|
| vitest/valid-title | @vitest/eslint-plugin | empty, 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-plugin | tests 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-plugin | duplicate test names. The suite output is a feature list; duplicate entries make it useless as documentation. |
| vitest/prefer-each | @vitest/eslint-plugin | loops of duplicated it() blocks. it.each turns each row into its own line in the reporter, which reads as documentation. |
| vitest --reporter=verbose | Vitest | missing 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',
},
},
];Apply these rules in vitest.config.js. The full enforcement across every tenet lives on the implementation page.
| Rule | Tool | Catches |
|---|---|---|
| vitest/valid-title | @vitest/eslint-plugin | empty, non-string, duplicate-prefixed or space-padded test titles. |
| vitest/no-disabled-tests | @vitest/eslint-plugin | skipped tests left in main. |
| vitest/no-focused-tests | @vitest/eslint-plugin | “.only” left in committed tests. |
| vitest/expect-expect | @vitest/eslint-plugin | tests with no assertion. |
| vitest/padding-around-test-blocks | @vitest/eslint-plugin | tests crammed together with no padding. The shape of the file is part of its readability as documentation. |
| vitest --reporter=verbose | Vitest | missing test-level visibility in the run output. The verbose reporter prints each test name as a line. |
vitest.config.jsconfiguration snippet
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
include: ['**/*.{spec,test}.{ts,tsx}'],
reporters: ['verbose', 'json', 'html'],
outputFile: {
json: 'reports/vitest.json',
html: 'reports/vitest.html',
},
coverage: { reporter: ['text', 'lcov', 'html'], include: ['src/**'] },
}
});Apply these rules in pyproject.toml. The full enforcement across every tenet lives on the implementation page.
| Rule | Tool | Catches |
|---|---|---|
| PT001 / PT002 | Ruff (flake8-pytest-style) | fixture decorators with redundant parentheses or arguments: visual debt that hurts the test file’s readability as documentation. |
| PT003 | Ruff (flake8-pytest-style) | fixture-scope arguments that drift from the conventional shape, undermining the at-a-glance readability of the test file. |
| PT006 / PT007 | Ruff (flake8-pytest-style) | parametrize argument names and value tuples that don’t match the canonical shape. Parametrised tests are documentation only when the rows read cleanly. |
| PT017 | Ruff (flake8-pytest-style) | asserts inside except blocks that hide the actual failure mode. The test name promises a behaviour; the assertion has to be visible to deliver it. |
| pytest -v / --tb=short | pytest | low-fidelity test output. Verbose mode prints every test name; --tb=short keeps tracebacks readable so the sentence-name remains the headline. |
| pytest --strict-markers | pytest | typo’d markers that silently pass. A test marker is part of the spec’s shape; an unrecognised marker is documentation that lies. |
pyproject.tomlconfiguration snippet
[tool.pytest.ini_options]
addopts = "-v --tb=short --strict-markers --strict-config -ra"
testpaths = ["tests"]
python_files = ["test_*.py", "*_test.py"]
[tool.ruff.lint]
select = ["PT"]
[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = falseApply these rules in pmd-ruleset.xml. The full enforcement across every tenet lives on the implementation page.
| Rule | Tool | Catches |
|---|---|---|
| @DisplayName | JUnit 5 | method names doing the work of a sentence. @DisplayName("rejects an order whose total is negative") turns the reporter into a feature list. |
| @DisplayNameGeneration(ReplaceUnderscores) | JUnit 5 | the boilerplate of writing a separate display name for every method: the underscore replacer turns rejects_an_order_whose_total_is_negative into the same sentence in the reporter output. |
| UnitTestShouldIncludeAssert | PMD | tests with no assertion. A test without an assertion is a sentence with no verb: it can’t document anything. |
| UnitTestContainsTooManyAsserts | PMD | tests asserting more than one behaviour. Multiple assertions per test means one name pretending to document several things. |
| S2699 (no assertion) | SonarQube Java | JUnit tests that omit any assertion call. |
| S1607 (disabled tests) | SonarQube Java | @Disabled annotations with no rationale. A disabled test with no reason given is documentation that lies. |
| Maven Surefire reporter | Maven Surefire | low-fidelity test output. With the JUnit5 tree reporter configured, the Surefire console prints each display name; the XML reporter feeds CI dashboards that double as the feature list. |
pmd-ruleset.xmlconfiguration snippet
<?xml version="1.0"?>
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
name="LivingDocumentation">
<description>Tests as documentation: name them like sentences.</description>
<rule ref="category/java/bestpractices.xml/UnitTestShouldIncludeAssert"/>
<rule ref="category/java/bestpractices.xml/JUnitJupiterTestShouldBePackagePrivate"/>
<rule ref="category/java/bestpractices.xml/UnitTestContainsTooManyAsserts"/>
<rule ref="category/java/errorprone.xml/JUnitSpelling"/>
<rule ref="category/java/errorprone.xml/UnnecessaryCaseChange"/>
</ruleset>Apply these rules in phpunit.xml. The full enforcement across every tenet lives on the implementation page.
| Rule | Tool | Catches |
|---|---|---|
| testdox="true" | PHPUnit (testdox) | low-fidelity test output. Testdox mode prints each test method’s humanised name: the artefact stakeholders can read directly. |
| #[TestDox] attribute | PHPUnit (testdox) | method names that don’t humanise cleanly. The attribute overrides the default humaniser, giving precise control of the sentence. |
| displayDetailsOnTestsThatTriggerWarnings="true" | PHPUnit (testdox) | warnings hidden in the run output. A warning is a partial failure; it has to be visible to be honest documentation. |
| failOnWarning="true" | PHPUnit (testdox) | warnings that the suite tolerates. Promote them to failures and the build refuses to be green-yet-warning: the property TS1 needs. |
| PHPUnit\Framework\Assert::markTestSkipped | PHPUnit (testdox) | left-in markTestSkipped calls. Each skip is documentation that lies; pair with a CI gate that fails on any skip count above the agreed budget. |
| Squiz.NamingConventions.ValidFunctionName | PHP_CodeSniffer | method names that are not camelCase. It rejects snake_case test names, so use it only on camelCase suites. |
phpunit.xmlconfiguration snippet
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/13.3/phpunit.xsd"
testdox="true"
displayDetailsOnTestsThatTriggerWarnings="true"
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<text outputFile="coverage.txt"/>
</report>
</coverage>
</phpunit>AI rules
.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.
Counter-argument
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.
Counter-argument retort
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.
Notes
- [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]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]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.
- [4]Michael Bolton: “Testing vs. Checking” (developsense.com, 2009). Sets out the distinction: checking confirms existing beliefs, testing looks for new information. Later refined with James Bach. Extended to TS1: treating the test file as the spec rots the test from asking new questions into checking known answers.
- [5]Michael Nygard: Documenting Architecture Decisions (cognitect.com, 2011). The ADR pattern: numbered in sequence, superseded rather than edited, the artefact for the explanation half of Procida’s taxonomy.
- [6]Koen Claessen & John Hughes: “QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs” (ICFP 2000). The original property-based testing paper. Properties as the questioning view that regression nets lack.
- [7]Hillel Wayne: “The Myth of Self-Documenting Code” (buttondown.com/hillelwayne, 2021). Argues self-documentation is impossible because the writer brings invisible context the reader lacks. Extended to TS1: tests cannot encode the why on their own.
- [8]Dan North: “Introducing BDD” (dannorth.net, 2006). The article that named the practice and proposed Given/When/Then as a template for acceptance criteria, loose enough for analysts and structured enough to automate.
- [9]Kent Beck: Test Desiderata (kentbeck.github.io, 2019). Names the property as Predictive: if the tests all pass, the code under test should be suitable for production.
- [10]Gerard Meszaros: xUnit Test Patterns (Addison-Wesley, 2007). Catalogues “Tests as Documentation” and identifies the inverse smell “Obscure Test”. The reference text on the mechanics that earn the property.