What is mutation testing and how does it improve test quality?
- mutation testing
- test quality
- stryker
Answer it first, then compare. Nothing here is saved or scored.
Model answer
Mutation testing introduces small changes (mutations) to source code and checks if tests catch them. Mutations: change operators (+ to -), flip conditions (true to false), remove statements. If tests still pass with a mutation, those tests are weak. Benefits: (1) Reveals gaps that code coverage misses. (2) Forces meaningful assertions. (3) Identifies dead code. Tools: Stryker (JavaScript/TypeScript), PIT (Java). Limitations: slow (runs tests many times), can produce equivalent mutants (mutations that do not change behavior). Use on critical code paths, not entire codebase.
What interviewers listen for
- Risk-based prioritisationYou can defend skipping coverage on a path because the risk maths supports it.
- Test design fluencyYou apply equivalence partitioning and decision tables to concrete inputs in real time.
- Metric judgmentYou distinguish between metrics that drive learning and metrics that drive theatre.
- Strategy under constraintYou can produce a defensible plan when the team has half the time and twice the scope.