Notes
Green, but?
Start with the tests from the previous episode: a local model's pytest file for ShopRung's cart, after three small human fixes. Four tests passed: adding five mugs works, fifteen is refused, five more works, and an out of stock mug is refused with four oh nine. They look like reasonable cart tests. The question is whether they would ever fail.
llama3.2:3b, with API context
after 3 human fixes:
4 passed, 5 failed
the 4 that pass:
add 5 mugs → 200
add 15 mugs → 400
add 5 more → 200
add 10 of an out-of-stock
mug → 409 Grade them
Grade tests the way mutation testing does: introduce bugs and see whether the tests notice. ShopRung's bug switch gives you ten planted bugs. We turned them on one at a time. The four AI tests passed every time: zero of ten caught, including quantity limit, which is a cart bug these tests were meant to cover. The hand written API suite from lab eleven catches seven of those bugs.
quantity-limit 4 passed stock-not-reduced 4 passed coupon-boundary 4 passed order-leak 4 passed ... 6 more 4 passed bugs caught: 0 of 10 lab 11's hand-written suite: 7 bugs caught
Why
Why did they miss it? The bug lets a cart line hold eleven. The AI tests tried five and fifteen. Fifteen is refused with or without the bug, so the test cannot fail. Two hand written tests at the actual boundary, ten is allowed and the eleventh is refused, pass on the normal shop, and the eleventh fails the moment the bug is on. Boundaries come from the requirement, not from a plausible guess.
AI tests: 5 and 15
15 is refused either way
hand-written, 2 tests:
test_ten_is_allowed
test_eleventh_is_refused
normal shop: 2 passed
bug on: 1 failed,
1 passed Gate 1
The first gate: every new test must be seen failing once. Break the behaviour on purpose, with a bug switch, a wrong value or a feature flag, run the test and watch it fail with a clear message, then restore and watch it pass. A test nobody has seen fail is not yet a test. It is the same rule as red first in test driven development, and it would have exposed all four AI tests in a minute.
- break the code or the data on purpose: a bug switch, a wrong value, a feature flag
- run the new test: it must fail with a clear message
- restore: it must pass
- no red seen → not a test yet
- same rule as TDD's "red first"
Gate 2
The second gate grades whole suites: mutation testing. A tool changes the code in small ways, a greater than into greater or equal, ten into eleven, and checks that some test fails for each change. In lab eight, tests with eighty nine percent line coverage killed only forty five of seventy one mutants. Coverage says code ran; mutants say it was checked. Run it on AI written tests, and on code AI wrote.
- a tool changes the code: > to >=, 10 to 11, a removed call
- each change is a mutant; a test must fail for it to be "killed"
- lab 8: 89% line coverage, 45 of 71 mutants killed
- run it on AI-written tests and on code AI wrote
- PIT (Java), mutmut (Python)
Gate 3
The third gate is review, with a few additions for AI. Trace every expected value to a requirement. Check that imports, endpoints and fixtures exist, because that is where inventions hide. Check boundaries are tested at the limit. Reject new skips, retries and sleeps. When AI wrote the application code, write its tests from the requirement, not from the code, or they will share its mistakes. And every change has a human owner.
- every expected value traced to a requirement id
- imports, endpoints, fixtures: do they exist?
- boundaries tested at the limit
- no new skips, retries, sleeps
- tests for AI-written app code written from the requirement, not from the code
- a named human owner
In CI
Then automate what you can. A CI job runs changed tests against planted bugs and fails if none of them fail. Mutation testing runs on changed files with a minimum score. A diff check blocks new skip, only, fix me and retry settings. Coverage stays a floor, not a goal. Some teams also label AI assisted pull requests, so reviewers know to apply the extra checks.
- changed tests must fail on a planted bug (bug switch job)
- mutation score on changed files, with a minimum
- block .skip, .only, fixme, retries in diffs
- coverage is a floor, not a goal
- label AI-assisted pull requests
Common mistakes
Mistakes. Treating green as done. Treating coverage as proof. Generating tests from the same AI written code they are meant to check, so both share the same misunderstanding. Never running tests against a planted bug or a mutant. Guessing boundaries instead of taking them from the rules. And merging changes nobody owns.
- green = done
- coverage as proof
- tests generated from the same AI code they test
- no planted bug or mutant run
- boundaries guessed, not taken from rules
- nobody owns the change
Say it like this
In the interview: I do not trust green. Every new test must be seen failing once on a planted bug, suites are graded with mutation testing, and expected values come from the requirements, not from the code. In one trial, AI written cart tests that passed caught zero of ten planted bugs, while two hand written boundary tests caught the quantity bug immediately.
- "I don't trust green. Every new test must fail once on a planted
- bug; suites are graded with mutation testing; expectations
- come from requirements. In one trial, AI-written cart tests
- caught 0 of 10 planted bugs, while two boundary tests caught
- the quantity bug at once."