Mutation testing

A tool deliberately changes your code and checks whether the test suite turns red, exposing assertions that never notice wrong behavior.

break the code and see if tests failtest whether my tests catch bugschange plus to minus in the sourcetests pass even when code is wrongStryker mutation scoremutation testngkill the mutantshow strong is my test suite

What it is

Mutation testing makes small, mechanical changes to production code, such as replacing `>` with `>=`, flipping a boolean, or removing a method call, then runs the tests. If a test fails, the mutant was killed. If the suite stays green, the mutant survived and exposed a behavior your assertions may not protect. DeMillo, Lipton, and Sayward described the technique in 1978; today Stryker is the common choice for JavaScript and TypeScript, and PIT fills the same role on the JVM.

Run it on valuable logic after ordinary coverage looks healthy. It is especially good at finding tests that execute a line without checking its result, which statement coverage cannot distinguish from a useful test.

Gotcha: mutation testing is computationally expensive because it runs the suite again and again. Some surviving mutants are equivalent to the original program and cannot be killed by any test. Treat the mutation score as a lead generator, not a target worth gaming.

Ask AI for it

Add mutation testing to this TypeScript project with StrykerJS and its Vitest runner. Mutate only `src/**/*.ts`, exclude generated files and test files, enable incremental mode, and configure `thresholds` with high, low, and break values. Run the first report with the html and clear-text reporters, list the surviving mutants by source line, and add focused assertions that kill meaningful survivors. Mark an equivalent mutant ignored only after explaining why no observable input can distinguish it.

You might have meant

unit testcode coverageregression testtest suiteassertion