Mutation testing

Mutation testing image

What is mutation testing?

Mutation testing evaluates test quality by deliberately introducing small code changes ("mutations") and seeing if your tests catch them. 

It's essentially the process of systematically and purposely planting bugs to check if your warning systems work. When tests fail after a mutation, it confirms they're actually verifying the code's behavior, not just going through motions.

Do you have any examples of mutation testing?

A developer might change if (balance > 0) to if (balance >= 0) or flip a plus to minus (total = price + tax becomes total = price - tax). These tiny changes should trigger test failures. Tools like PIT for Java or Stryker for JavaScript automate this process by generating hundreds of these mutations and tracking which ones your tests catch.

Why is mutation testing important?

Mutation testing reveals blind spots in your test suite that test coverage metrics miss. You might have 100% line coverage but still miss critical bugs if your assertions aren't thorough. It helps teams write meaningful tests rather than superficial ones. 

For testers specifically, it provides concrete evidence of test effectiveness and helps prioritize which areas need better testing.

What are the challenges of mutation testing?

Mutation testing is computationally expensive—running your entire test suite against hundreds of code variations takes time. Some mutations create equivalent code that behaves identically (making them impossible to detect), while others introduce unrealistic bugs. Most teams run mutation testing periodically rather than in every build. Modern tools like Pitest help by parallelizing tests and using smart sampling to focus on the most valuable mutations.


I see mutation testing as a process for thoroughly testing our tests to ensure that we can really rely on them. My recommendation is to do mutation testing every time you create or edit a test. You should also review your automated tests making sure it is still relevant. You should do this regularly. You'll need to make sure that tests keeps up to date
with changes to the software. 

My process for mutation testing involves going through all the steps of a test and listing all the ways each individual step could fail. I then attempt to simulate these failures by either changing the state of the software before the test is run, running the test in debug mode, and then pausing the test using breakpoints to try and simulate a failure, changing the software at that point, or adjusting the test code itself to check the accuracy. Another reason I find mutation testing useful is because it allows me to design the tests to give useful messages if certain failures have occurred.
MoT Professional Membership image
For the advancement of software testing and quality engineering
Explore MoT
Software Quality in the AI-First Landscape image
Thu, 24 Apr
The Al wave is here, and QA teams are at a turning point
MoT Software Testing Essentials Certificate image
Boost your career in software testing with the MoT Software Testing Essentials Certificate. Learn essential skills, from basic testing techniques to advanced risk analysis, crafted by industry experts. Early access available now at a discounted rate!
Leading with Quality
A one-day educational experience to help business lead with expanding quality engineering and testing practices.
This Week in Testing image
Debrief the week in Testing via a community radio show hosted by Simon Tomes and members of the community
Subscribe to our newsletter
We'll keep you up to date on all the testing trends.