Home / Knowledge hub / Mutation testing
Knowledge hub
Mutation testing
Deliberately changing code to check whether your tests notice the change.
What it means
Mutation testing is a way of testing your tests. A tool makes small deliberate changes to the code, such as flipping a comparison or removing a condition, and then runs the test suite. If the tests still pass, they did not notice the change, and that gap is reported. The idea comes from software quality research and is used in many languages.
Each change is a mutant. A mutant the tests catch is killed. One that survives points at behaviour the tests do not really check. The result is a score for how well the tests would detect real mistakes, not just whether they pass today.
Why it matters
Code coverage can mislead. A line can run during a test without any check on what it did. Mutation testing asks the harder question of whether a wrong result would be noticed. A suite with high coverage and many surviving mutants gives false confidence. Tests that pass no matter what the code does are worse than no tests, because people trust them.
For security this matters at access checks. If you flip a permission check from deny to allow and every test still passes, nothing guards that rule. Mutation results show where regressions could slip in unnoticed. Prioritise those areas first. Start with access checks.
How it shows up
You meet it through tools such as Stryker for JavaScript and C#, PIT for Java, and others for most languages. They are slow, because the suite runs once per mutant, so teams run them on the most important modules or on changed code only.
Mistakes: running it across the whole codebase and giving up at the runtime, chasing a 100 per cent score, and not looking at survivors that sit in security-critical code. Start with authentication, authorisation and payment logic. It checks your tests; it is not a replacement for penetration testing.
Questions people ask
Mutation testing, answered
Is mutation testing a security test?
Not directly. It measures the quality of your own tests, not the application's exposure to attackers.
It is useful for security because it shows which important checks have no test protecting them.
How is it different from code coverage?
Coverage shows which lines ran. Mutation testing shows whether the tests would notice a change to those lines.
A line can be covered and still be unchecked. That is the gap mutation testing exposes.
Is it the same as fuzzing?
No. Fuzzing changes the inputs to a program to find crashes and flaws. Mutation testing changes the program itself to test the tests.
They share a name root but have different goals.
Why is it slow?
The test suite runs once for each mutant, and there can be thousands. Tools reduce this by running only relevant tests per mutant.
Limit it to critical modules or recent changes.
What is a good mutation score?
There is no universal number. Compare over time and focus on survivors in sensitive code.
Chasing a perfect score wastes effort on trivial mutants. Use trends over time.
Sources
Where this comes from
Related
Terms that sit next to this one
Regression
A bug that was fixed and has come back, usually undone by a later change.
Fuzzing
Throwing malformed input at an application to see what falls over.
Security regression test
An automated test that fails if a fixed vulnerability ever returns.
Security test coverage
How much of your application a security test actually reached.
Secure code review
Reading code specifically to spot security flaws before they ship.
Do your tests guard the checks?
Passing tests do not prove a flaw is gone. We test the running app, report what we actually exploited, and replay the exploit against the new code to confirm the fix. Book a pilot on one app.
Or start with a $199 pilot on one application: thirty days, success criteria agreed before day one, credited against the annual if you convert.