Infection is a PHP mutation-testing tool that checks whether a test suite detects deliberate changes to source code. It creates mutations using predefined operators, runs tests covering changed lines, and records which mutations tests catch, which survive, and any errors or timeouts. Its Mutation Score Indicator measures the share of generated mutations detected by tests; it also reports Mutation Code Coverage and Covered Code Mutation Score Indicator. Infection supports PHPUnit, PhpSpec, Codeception, and Testo, and runs from a project root as a command-line tool. Teams can run mutated tests in parallel, focus on changed lines or files, and set minimum score thresholds that can fail a build. Optional PHPStan and Mago integrations help identify escaped mutations involving type violations, dead code, or unreachable paths. A browser playground lets users try PHP code and tests without installing the toolchain. Infection requires PHP 8.3 or newer and Xdebug, phpdbg, or pcov. It is free and released under the BSD-3-Clause license.
Who it is for
Infection suits PHP developers who want to assess whether their tests catch code changes, including teams enforcing mutation-score thresholds in CI. The browser playground may suit people exploring mutation testing without installing the tools.
What is good
- Works with PHPUnit, PhpSpec, Codeception, and Testo.
- Can focus mutations on changed lines or files.
- Minimum mutation scores can fail a build.
- Browser playground runs PHP mutation tests without installation.
What to know first
- Requires PHP 8.3 or newer.
- Requires Xdebug, phpdbg, or pcov.
- Parallel runs may give false positives for interdependent or database tests.
- Only the latest version is covered by the security policy.
Verdict
Infection offers a range of mutation metrics and controls for targeting changes or setting build thresholds. Check the PHP and coverage-driver requirements, and use care with parallel runs when tests depend on one another or a database.
Compared on mutation testing tools
- Free plan
- Yes
- Supported languages
- PHP
- Test frameworks
- PHPUnit, PhpSpec, Codeception, Testo
- Incremental analysis
- Yes
- Parallel execution
- Yes
- Surviving mutant reports
- Yes
- Mutation quality gate
- Yes
- Mutation operators
- Arithmetic, boolean, cast, conditional boundary, conditional negotiation, equality, function signature, nullify, number, operator, regex, removal, return value, visibility, and unwrap mutators



