What Is Mutation Testing?
Mutation testing is a technique that evaluates the quality of a test suite by introducing small, deliberate changes (mutants) to the source code and checking whether the tests detect and fail on those changes.
Free to start · 7-day trial on paid plans
In Depth
The premise is simple: if your tests are effective, any meaningful change to the code should cause at least one test to fail. A mutation testing tool generates mutants by applying operators like replacing + with -, changing true to false, removing method calls, or altering boundary conditions. Each mutant is a copy of the code with one small change. The tool runs the test suite against each mutant. If a test fails, the mutant is "killed" (detected). If all tests pass, the mutant "survives," indicating a gap in your tests.
The mutation score is the percentage of killed mutants. A score of 85% means your tests detect 85% of injected faults. Unlike code coverage, which only measures execution, mutation testing measures detection power. A test can cover a line without catching bugs on that line; mutation testing exposes this weakness.
Tools like Stryker (JavaScript/TypeScript), PITest (Java), and mutmut (Python) automate the process. The main trade-off is execution time: generating and testing hundreds of mutants is computationally expensive. Teams typically run mutation testing on critical modules or as a periodic quality audit rather than on every commit.
Why Interviewers Ask About This
Mutation testing is an advanced topic that demonstrates deep knowledge of test quality. Mentioning it shows you go beyond basic coverage metrics to truly evaluate test effectiveness.
Example Scenario
After achieving 95% line coverage on a pricing engine, the team runs Stryker and discovers a mutation score of only 68%. Many surviving mutants involve changed comparison operators (>= to >) in discount calculations. The team adds targeted assertions for boundary conditions, raising the mutation score to 91%.
Interview Tip
Position mutation testing as a complement to code coverage. Explain the concept of killed vs. surviving mutants and mention a specific tool. This is a great way to stand out in senior-level interviews.
Related Terms
Explore related glossary terms to deepen your understanding.
Related Resources
Dive deeper with these related interview prep pages.
Ready to Ace Your QA Interview?
Practice explaining mutation testing and other key concepts with our AI interviewer.
Join 1,200+ QA engineers already practicing with AssertHired.
Start Your Free QA InterviewFree to start · 7-day trial on paid plans