See it fail: red before green and break-it checks
Confirm a new test is red without the fix and green with it. Temporarily break the code to check that the suite catches the break, which is the core idea of mutation testing.
Builds on: What makes a test able to fail
Green, but would it ever have been red?
You asked the agent to fix a bug: a discount above 100% gave a negative price. It replies: “Fixed `apply_discount` and added a regression test. All 212 tests pass.”
The suite is green. But that run only shows the new test passes on the *fixed* code. Would the same test have gone red on the old, buggy code? Nobody has checked that yet.
One green run can't tell good from useless
The agent wrote the fix and the test together. It only ran the test against the fixed code. In that run, a test that catches the bug and a test that misses it look the same: both green.
Common misses: inputs that never reach the bug, a call to the wrong function, an assertion that holds either way. **Later cost:** the bug returns in a later change, the test stays green, and everyone trusts it.
The two checks, step by step
**Red before green**
1. While the fix is still uncommitted, remove it but keep the test: `git stash push -- <source files>`.
2. Run the new test. It must be **red** *for the right reason*: an assertion showing the buggy value, not an import or compile error.
3. Restore the fix (`git stash pop`). It must be **green**.
**Break-it check:** make one small wrong change the tests should notice, such as flipping `<` to `<=` or returning a constant. The suite must go red. Then revert. This is the core idea of mutation testing, done by hand. A mutation testing tool makes many such changes automatically.
Fix removed, test still green
You stash only the fix and rerun the agent's test. It still passes. That is the **tell**: this test cannot see the bug. Its input is a 50% discount, which never reaches the over-100% path. **Later cost:** the bug can come back in a later change, and this test will stay green while it does.
The trustworthy test calls `apply_discount(100.0, 120)` and expects `0.0`. Without the fix it is red, and the assertion shows a negative price such as `-20.0`. With the fix it is green. Now it guards the bug.
// Python
$ git stash push -- src/pricing.py
$ pytest tests/test_pricing.py::test_discount_regression -q
. [100%]
1 passed in 0.02s
$ git stash pop
Break-it check in Go
The agent added `func IsAdult(age int) bool { return age >= 18 }`, with tests for ages 30 and 10. All green.
Break it on purpose: change `>=` to `>` and run `go test ./...`. Still `ok`. No test sits at 18, so an off-by-one there would ship. Add the case `IsAdult(18) == true`, taken from the spec, and rerun the broken version: red. Revert the break: green. Keep the new case.
Only trust a test you've seen fail
A test proves something only if you have seen it fail. It should be red without the fix, for the right reason, and green with it.
Then break the code on purpose. If the suite stays green, you have found a gap that a real bug could slip through.
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.