Worked example · Testing

Getting a failing test suite to green with WDD

The simplest Whiplash Driven Development loop: the test suite is the verifier, the agent fixes one failure at a time and is sent back after every claim of success until the whole suite passes, with the tests themselves off limits.

The goal

Make all 140 failing tests in a legacy service pass after a framework upgrade, without changing the tests.

The verifier

The full test suite (for example npm test or pytest), plus a check that no test file changed.

Why this check: The suite says what is broken; the second check closes the easiest way to cheat.

The set-up

  • A branch or worktree just for this, and a container to run it in.
  • A pre-commit check (or the verifier itself) that fails if any file under tests/ changed.
  • AGENTS.md with the "tests are sacred" rule.

The kickoff prompt

Kickoff

Make the full test suite pass. Do not change any file under tests/. Run the suite, take the first failure, fix its cause in the code, run the suite again. Keep going until it passes. Make no mistakes.

How the rounds went

Rounds 1 to 5
Most failures share three causes (a renamed import, a changed default, a removed helper). Fixing those clears 110 tests.
Rounds 6 to 12
The remaining 30 are individual. The agent twice declares "all tests pass" after running only one file; the push pastes the full suite output back each time.
Round 13
The whole suite passes; the test-file check passes; the diff touches only application code.

What worked

  • Grouping failures by cause first: a few fixes cleared most of the red.
  • Pasting the full output into the push, so "it passes" had to mean the whole suite.
  • Making test files read-only to the loop.

What to watch for

  • Agents like to run a single test file and generalise. The loop script should always run the full verifier itself.
  • Skipped tests are failures in disguise: make the verifier fail on skips.

Build a kit for a task like this

A worked example written to show the method, not a report of a specific project.

Questions people ask

What stops the agent from just deleting the failing tests?

A rule in AGENTS.md, and, more reliably, a check in the verifier that fails if any test file changed or any test is skipped.

Is it fine to let the agent run without watching?

Inside a container or VM, on a branch, with a round limit: yes, that is the point. Read the final diff before you merge.

More examples