Write tests that disagree with broken code
hard 12 minChoose assertions that can distinguish a correct service from a plausible defective one.
Theory
Read or listen first. About 1 min.
What it is
A generated reservation suite has forty tests. Each checks for a success response. A one-line change that debits one unit for a two-unit claim still passes all forty.
Why it exists
Write the expected response and the expected state separately. Derive the state from the requirement using literal quantities. Run the same assertion against a deliberately changed implementation. A surviving change identifies a blind spot; a killed change only demonstrates coverage of that particular fault.
One request, three implementations
| Service | Returned status | After reserving 2 of 3 |
|---|---|---|
| Correct | held | 1 available |
| Always debit one | held | 2 available |
| Response only | held | 3 available |
Understand it
Work through the decision
A response assertion checks the client-facing contract but misses an incorrect write.
Pair it with a stored balance and a repeat operation. These observables catch more faults while keeping internal implementation details flexible.
Give the agent a check
- Calculate a small example on paper and ask the assistant to find an implementation that satisfies the current tests but breaks that example.
The shortcut
- Generate expected results by calling the helper used in the service.
What a reviewer can hear
| Signal | Example |
|---|---|
| Weak | Generate expected results by calling the helper used in the service. |
| Competent | The independently calculated remaining balance of one, together with a successful hold. |
| Strong | It establishes sensitivity to this sample of faults. New policies and interleavings can introduce other failure modes. |
Summary
The whole topic in one minute.
Change the code on purpose. Which test notices?