Blog
Mutation Testing: Make Sure Your Assertions Can Kill A Bug
A test can execute an if statement and never prove its condition matters. Coverage paints the line green anyway.
Mutation testing changes code deliberately and asks whether the suite notices.
A Survivor Is A Question
Change > to >=, remove a method call, or replace a return value. If tests stay green, either an assertion is weak, a boundary is missing, or the mutation is behaviorally equivalent.
boolean allowed(Money used, Money limit) {
return used.compareTo(limit) <= 0;
}
A mutant changing <= to < should die on the exact-limit case.
Do Not Mutate The Universe First
Run mutation analysis on dense business logic and recently changed modules. Generated DTOs and trivial accessors create noise and cost.
Review survivors; do not chase a 100% mutation score blindly. Equivalent mutants may not be killable, and low-value code still remains low value.
Mutation runs also need a stable baseline. If ordinary tests are flaky, a surviving mutant is ambiguous and the analysis multiplies the noise. Repair nondeterminism first, then compare mutation results over changed code rather than treating the score as an organization-wide ranking.
The useful metric is not trophy number. It is the list of business decisions your assertions failed to defend.