Chapter 10: Tests

So here is how you test the tests. Break the code on purpose, in small ways, and see whether anybody notices.

Mutation testing

A tool makes one small deliberate bug in your code, such as changing a < to <=, and runs your tests. If they fail, that bug was caught. If they still pass, your tests have a blind spot exactly there.

This is the check that makes it hard for an agent to mark its own homework, because it doesn't trust the green. And a surviving mutant is a perfect instruction: it names a line and a change no test noticed.

Say it to your agent

“Run bunx stryker run on src/price.ts. For every survivor, either add a test that kills it, or explain why it can't be killed. Don't delete code to raise the score without saying so. Show me the before and after.”

The workshop

Name a word, or describe what you mean in everyday language.