Mutation Testing
Mutation Testing evaluates how effective a test suite is. A tool makes small, deliberate changes to the source code, called mutants, such as flipping a comparison or removing a line, and then runs the tests. If a test fails, the mutant is killed; if every test still passes, the mutant survives, revealing a gap in the tests.
Key components of mutation testing include:
- Mutation Operators: Rules for changing code, such as replacing > with >=, swapping arithmetic operators or negating conditions.
- Mutation Score: The percentage of mutants killed by the tests, which reflects how well the suite detects real faults.
- Surviving Mutants: Each survivor points to behavior no test checks, guiding where new assertions are needed.
- Equivalent Mutants: Some changes do not alter behavior at all and can never be killed, so they are excluded from the score.
- Tooling: Tools such as PIT for Java and Stryker for JavaScript automate generating and running mutants.
Code coverage shows which lines tests execute, while mutation testing shows whether those tests would actually notice if the code were wrong.


