Play · Tests you can trust
Green is easy to fake. Make it hard.
An agent is told to make the tests pass. Four pillars make sure it passes them by fixing the code.
Test integrityArchitecture as a gateValidation gatesClean code & commentsThe team, files and output on this page are invented to illustrate.
The question
The agent says all tests pass. Can you believe it?
Same bug, same agent, same deadline. One repo trusts the green. The other checks how it got there.
1A test fails
Green is green- expect(total).toBe(1200) + expect(total).toBe(1188)
Green, by changing the answer.
Reasons to trust it: 0 / 4
Green is checkedtest-integrity: assertion changed invoice.test.ts:42 needs the test owner
Caught, and sent to a person.
Reasons to trust it: 1 / 4
2A shortcut
Green is green// ui/InvoiceView.tsx import { db } from '../infra/db'
It works. The layers are gone.
Reasons to trust it: 0 / 4
Green is checkedarch: ui/ may not import infra/ ui/InvoiceView.tsx:3
The boundary holds.
Reasons to trust it: 2 / 4
3A flaky test
Green is greenit.skip('rounds tax per line') # 47 passed, 1 skipped
Quietly switched off.
Reasons to trust it: 0 / 4
Green is checked$ pnpm validate no new skips: 1 found FAILED
One command, no quiet skips.
Reasons to trust it: 3 / 4
4The reviewer reads it
Green is green// fix for PROJ-88 // add 12 to the total
What, not why.
Reasons to trust it: 0 / 4
Green is checked// Tax rounds per line, not per invoice. // See ADR 0011.
The why, with a pointer.
Reasons to trust it: 4 / 4
The chain
Each pillar closes one easy way to green
- Test integrityProtected testschanging one needs its ownerWithout it: the answer edited to match
- Architecture as a gateBoundaries as a checka forbidden import failsWithout it: layers that erode one shortcut at a time
- Validation gatesOne commandno quiet skipsWithout it: whichever tests still run
- Clean code & commentsComments that say whyso a reviewer can judge the fixWithout it: a ticket number and a guess
The gains
For the agent
- A clear no when it takes a shortcut
- Rules it can run, not guess
- Less rework after review
For the team
- A green that means something
- Architecture that survives fast changes
- Reviews about intent, not detective work
Try it on your repo
Break one test on purpose. Ask an agent to make it pass.
Look at how it got to green. If it touched the test, nothing stopped it.