Command Line Options

Besides general Symfony Console application command line options, Infection has its own ones.


If you’re only interested in mutating a subset of your files, you can pass a --filter option containing:

This in no way restricts the initial Infection check on the overall test suite which is still executed in full to ensure all tests are passing correctly before proceeding.

--threads or -j

If you want to run tests for mutated code in parallel, set this to something > 1. It will dramatically speed up mutation process. Please note that if your tests somehow depends on each other or use database, this option can lead to failing tests which give many false-positives results.

To automatically detect the number of CPU cores, use --threads=max.

For Infection versions below 0.26.15, you can detect the number of CPU cores depending on OS:

# on Linux
infection -j$(nproc)

# on OSX
infection -j$(sysctl -n hw.ncpu)

Running Infection with more threads not necessarily leads to better performance. Consider benchmarking several numbers to find one that works best for your particular case.


This is a name of the Test Framework to use. Currently, Infection supports PHPUnit, PhpSpec, Pest and Codeception.

If you are using infection/infection Composer package, PHPUnit and Pest are installed by default. Other test framework adapters will be automatically installed on demand.
PHAR distribution is bundled with all available adapters.

Feel free to request a new test framework to be supported out of the box in Github’s issues.


This option allows passing additional options to the test framework. Example for PHPUnit:

infection.phar --test-framework-options="--verbose --filter=just/unit/tests"

This will execute the PHPUnit as:

phpunit [...infection options] --verbose --filter=just/unit/tests

Please note that if you choose to use --configuration, --filter, or --testsuite for PHPUnit, these options will only be applied to the initial test run. Each mutation has a custom phpunit.xml file generated for it which defines a single testsuite containing the tests which should be executed for that mutation. Applying --filter or --testsuite would not make sense in this context as the tests have already been filtered down.


Path to the existing coverage reports.

When you use Continuous Integration for your project, probably you are already generating code coverage metrics and run PHPUnit with Xdebug/phpdbg enabled. Then, you run Infection for mutation testing, which in its turn, generates Code Coverage again for internal needs. This dramatically increases the build time because running your tests with debugger twice requires too much time.

With this option it’s possible to reuse already generated coverage in Infection.

For PHPUnit and Codeception:

For PhpSpec:


# collect coverage
vendor/bin/phpunit --coverage-xml=build/coverage/coverage-xml --log-junit=build/coverage/junit.xml

# use coverage
infection.phar --coverage=build/coverage


Allows filtering files to mutate by using git diff with --diff-filter option. Sensible values are: AM - added and modified files. A - only added files.

Best to be used during pull request builds on CI, e.g. with GitHub Actions, Travis CI and so on.


# this is needed on GitHub Actions to fetch the base branch to make a diff
git fetch --depth=1 origin $GITHUB_BASE_REF

infection.phar --git-diff-filter=A

This command will mutate only those files that were added in the Pull Request. The diff is done between the current branch and a common ancestor of it and the base branch. If there is no common ancestor available, perhaps because your CI server used a shallow checkout, or you have unrelated branches, infection will use a direct diff between branches as a fallback.

It’s possible to configure the base branch, see --git-diff-base option

It’s possible to mutate only touched lines, see --git-diff-lines option


Supposed to be used only with --git-diff-filter option. Configures the base branch for git diff command.


# this is needed on GitHub Actions to fetch the base branch to make a diff
git fetch --depth=1 origin $GITHUB_BASE_REF

infection.phar --git-diff-base=origin/$GITHUB_BASE_REF --git-diff-filter=AM


Allows mutating only touched lines of code. Under the hood, this option mutates only added and changed files, comparing your current branch with master branch by default.

Base branch can be changed by using --git-diff-base=main option. In this case, your current branch will be compared with main branch.

Useful to check how your changes impacts MSI in a feature branch. Useful for those who do not want / can’t write tests for the whole touched legacy file, but wants to cover their own changes (only modified lines).

Can significantly improve performance since fewer Mutants are generated in comparison to using --git-diff-filter=AM or mutating all files.


Supposed to be used only with GitHub Actions. This logger prints GitHub Annotation warnings for escaped Mutants right in the Pull Request.

Note that the Github Actions environment is automatically detected and this switch isn’t actually necessary when executed there.

GitHub Annotation Escaped Mutant


# this is needed on GitHub Actions to fetch the base branch to make a diff
git fetch --depth=1 origin $GITHUB_BASE_REF

infection.phar --logger-github --git-diff-filter=A

Here is a real example how Infection uses it itself.


This option is used to provide a path to the generated HTML Report:

infection.phar --logger-html='mutation-report.html'

After Infection completes its job, the mutation-report.html file will be generated with HTML report (example).

Takes precedence over logger.html setting inside infection.json5 file. If you want to always generate HTML report, it’s better to configure it inside infection.json5, see here.

If you want to store HTML report in the cloud (useful for OSS projects), see Stryker Dashboard integration


If you have already run the test suite to ensure it is passing, and you are providing coverage using --coverage then you can use this option to increase performance by not running the entire test suite again.

Note that it is extremely important that you ensure the test suite is passing when using this option, otherwise test failures would appear like caught mutations and those mutations may be reported incorrectly.


Run the mutation testing only for covered by tests files.


Execute only those test cases that cover mutated line, not the whole test file with covering test cases. Can dramatically speed up Mutation Testing for slow test suites, like functional or integration.

For PHPUnit / Pest it uses --filter option under the hood. This option is not applicable for other test frameworks.

Read more about the problem and solution in this blog post

--show-mutations or -s

Show colorized diffs of mutated files to the console. Only escaped mutants are shown by default.

Please note that all mutations are logged to the infection.log file as well.

--configuration or -c

If you want to use custom configuration file path or name, use this option for it.


This is a minimum threshold of Mutation Score Indicator (MSI) in percentage. Can be used with CI server to automatically control tests quality.

Read more about using Infection in CI server


This is a minimum threshold of Covered Code Mutation Score Indicator (MSI) in percentage. Can be used with CI server to automatically control tests quality.


This is a comma separated option to specify a particular set of mutators or profiles that need to be executed. Example:

infection --mutators=PublicVisibility,Plus,Decrement,@number

See here to find all mutator names.


This option has two effects:

Disabling progress bars removes the following lines from output on Continuous Integration servers:

Processing source code files: 0/5678
Processing source code files: 1/5678
Processing source code files: 2/5678
Processing source code files: 3/5678
5k lines of text
Processing source code files: 5678/5678

Progress bar display will be automatically disabled with or without this option when either CI or CONTINUOUS_INTEGRATION environment variables are set to "true".

For example, there is no need to enable this option manually on Travis CI just to hide progress bars.


Use noop mutators that do not change the AST. For debugging purposes.

Read about debugging issues with --noop option here


Outputs progress bars and mutation count during progress even if a CI is detected.

This option also reverts optimizations made by --no-progress option, read here.


This is a name of console output formatter. Possible values are: dot, progress. Default is dot formatter.


The verbosity of the log file, all - this mode will add “Killed mutants” into log file and add additional information, default - normal mode will skip “Killed mutants” section in the log file, none - which will disable logging to files.

infection --log-verbosity=all


Run Initial Tests process with additional php options. For example with -d which will run Xdebug only for code coverage.
May be useful for cases when Xdebug is not enabled globally. Also it’s useful from performance point of view.

infection --initial-tests-php-options="-d"


Ignore MSI violations when no mutations are generated. This will force Infection to return a zero exit code even when the required MSI is not reached.


Run Infection in a debug mode. With this option Infection will not erase tmpDir and this might be useful to run particular unit test with a mutated code for example.

Also, this option will add test framework’s output to log file so you can analyze by which test particular Mutant was killed, and additional information about executed command lines will be added.