A pull request lands with 40 new tests and 96% line coverage. An assistant wrote the code, and an assistant wrote the tests. The build is green.
Coverage only tells you which lines ran. It doesn’t tell you whether a test would fail if one of those lines were wrong. That gap matters more when you’re validating AI-generated code, because the code and its tests both arrive quickly and both look reasonable. Mutation testing closes the gap by intentionally planting small bugs and checking whether your tests notice.
Green Tests Can Still Miss the Bug
Picture a function that applies a loyalty discount. A generated test calls it with a sample order and checks that the result is a number greater than zero. Every line runs, so coverage looks great. Yet if the discount were 15% instead of 10%, the test would still pass.
That kind of weak assertion is easy to miss in review. It also matters more as AI writes more of the code. CodeRabbit’s December 2025 analysis of 470 open-source pull requests found that AI-assisted changes carried about 1.7 times as many issues as human-only changes. Logic and correctness errors showed up about 1.75 times as often.
Logic errors are exactly what a test with real assertions should catch. The question is how you prove your tests have them.
What Mutation Scores Add to Testing AI-Generated Code
A mutation tool makes small changes to your code, one at a time. It might flip a comparison or delete a line. Each changed version is a mutant, and the tool runs your tests against each one. If a test fails, that test killed the mutant. If all tests still pass, the mutant survived.
The mutation score is the share of mutants your tests killed. PIT does this for Java, Stryker covers JavaScript, TypeScript, and C#, and mutmut handles Python.
For testing AI-generated code, that score answers the question coverage can’t. It shows whether your tests check behavior or only run it. Report the two numbers side by side. High coverage with a low mutation score is a clear sign of tests that run code without checking it.
The approach also works well alongside AI. Meta now uses language models to generate mutants and the tests that catch them. In one compliance project, its privacy engineers accepted 73% of the generated tests, according to InfoQ’s January 2026 report.
Six Mutants Worth Running First
Full mutation runs can take a while. Start with the changes that expose weak assertions most often.
- Flipped Boundaries. Change a “less than” check to “less than or equal”, and see whether any test notices it.
- Removed Null Checks. Delete a guard clause, then confirm some test feeds the function an empty or missing value.
- Negated Conditions. Turn a true branch into a false one to see whether both paths have real assertions.
- Changed Constants. Alter a rate, limit, or rounding value, since a test that only checks that a number came back will miss it.
- Deleted Calls. Remove a call that writes an audit log or sends a notification, and check whether any test looks for that side effect.
- Swallowed Errors. Replace an error path with a silent return, which shows whether tests check what happens when things go wrong.
Most mutation tools include these operators by default. You’re choosing where to look first, not adding anything new.
Reading AI-Generated Code Quality Through Surviving Mutants
A surviving mutant points to one of three things. The first is a weak test, and the fix is a sharper assertion. The second is code that no behavior depends on. If no test notices when that branch changes, the assistant may have written logic the feature never needed. That’s a useful signal about AI-generated code quality, since extra code adds review and maintenance effort with nothing in return. Before anyone writes a test for that branch, ask the author whether the feature needs it. Deleting the branch may be the better fix.
The third is an equivalent mutant. Some changes don’t alter behavior at all, like reordering two independent statements. Mark those once and move on.
Track survivors by module over a few sprints. A module where survivors keep piling up deserves a closer look at both its code and its tests.
Budgeting Time for Validating AI-Generated Code in CI
Mutation testing costs compute, because each mutant reruns part of your suite. A full run on a large codebase can take hours. That cost is manageable with a little structure.
On pull requests, mutate only the lines that changed. Most tools support this, and a run scoped to one change can finish in minutes. Save the full run for a nightly or weekly job. If even the scoped run is slow, sample a fixed share of mutants and widen the sample for high-risk files. Cache results between runs so the tool skips code that hasn’t changed. Give the job its own pipeline stage, too, so a slow run never blocks an urgent fix.
Publish the survivor list in the pull request itself. A reviewer reading “a negated-condition mutant survived on this branch” knows exactly what to ask.
Set Mutation Targets by How Much a Module Matters
A single score target for the whole codebase rarely works. Payment logic and permission checks deserve a higher bar than a settings page or a layout helper.
Start by measuring where each module stands today. Then set a target a little above that baseline for your most critical modules, and raise it as the tests improve. If your checkout tests kill 58% of mutants today, a target of 65% by next quarter is a fair ask. For lower-risk code, it’s often enough to watch that the score doesn’t drop.
Don’t chase 100%. Equivalent mutants make it unreachable, and the last few points rarely protect anything a user would notice.
A Surviving Mutant Is a Question Worth Answering
That pull request with 96% coverage looks different now. Run mutation testing on the changed lines, and the survivors tell you which behaviors no test checks. Each one turns into a specific question for the author. Should a test catch this change?
Validating AI-generated code gets easier when the evidence is that specific. Coverage says the code ran. Mutation testing shows whether anyone would know if it ran wrong.