Overview
Mutation testing changes code in controlled ways, such as replacing a comparison or altering a boolean condition. A useful test suite should fail for many of these mutations.
Infection workflow
Infection is a mutation testing framework for PHP. Install it as a development dependency, configure the source and test paths, and run it against a stable test suite. Follow the documentation for the installed version and required coverage driver.
Interpret results
A killed mutant is detected by the tests. A surviving mutant may indicate a missing assertion, an untested scenario or an equivalent mutation that does not change observable behavior.
Run selectively
Mutation testing can be more expensive than ordinary tests. Start with critical domain classes or changed files, then expand as runtime permits.
Improve the test
When a meaningful mutant survives, add a test that captures the missing behavior. Do not add assertions that merely encode the current implementation.