SteelReed

Search

Search posts, questions…

AI & LLMQuestion 21 / 25

Middle

AI-written tests are all green: how do you know they're worth anything?

Short answer

Use mutation testing: a tool (in Java, PIT) makes small changes to the code and reruns the tests; if they stay green, that behavior isn't checked. The mutant kill rate is more honest than line coverage.

redstill greenCode + AI-written testsPIT tweaks code> becomes >=Rerun the testsMutant killedMutant survived:behavior unchecked

3 points to say:

  1. A surviving mutant = the tests don't check that behavior, even though the line was executed.
  2. Line coverage doesn't measure assert quality: AI-written tests often assert back exactly what the mock returned.
  3. Write tests from the spec first, before letting AI implement; tests the same agent writes after the code can confirm its own bug.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.