- Command Line Options
- Using with CI
- Mutation Badge
- How-to Guides
- Infection Playground
- Compare with competitors
- What's new in Infection 0.17.0
- What's new in Infection 0.16.0
- What's new in Infection 0.15.0
- What's new in Infection 0.14.0
- What's new in Infection 0.13.0
- What's new in Infection 0.12.0
- What's new in Infection 0.11.0
- What's new in Infection 0.10.0
- What's new in Infection 0.9.0
- What's new in Infection 0.8.0
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:
a relative file path:
a relative directory path:
a comma separated list of relative paths:
a comma separated list of filenames:
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.
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.
On most platforms where GNU coreutils are available, which includes all variants of Linux, there is
nproc command that returns the number of processors available. It can be used as such to let Infection run at the full speed:
# on Linux
This is a name of the Test framework to use. Currently Infection supports
If you are using
infection/infection Composer package, only
PHPUnit is installed by default. Other test framework adapter 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 options allows to pass additional options to the test framework. Example for
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
--testsuitefor PHPUnit, these options will only be applied to the initial test run. Each mutation has a custom
phpunit.xmlfile generated for it which defines a single testsuite containing the tests which should be executed for that mutation. Applying
--testsuitewould 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
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.
- Infection requires both the
junitreports to work
build/coveragepath is provided, it should contain
- Infection requires the
xmlreport to work
build/coveragepath is provided, it should contain
# collect coverage
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.
Show colorized diffs of mutated files to the console.
Please note that all mutations are logged to the
infection.logfile as well.
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:
See here to find all mutator names.
This option has two effects:
- It disables intermediate buffering of mutations used to count them. This causes progress bars to not have a total number of mutations displayed, while also reducing memory usage and speeding up the entire process. It is beneficial during CI, and for larger projects.
- It disables dynamic progress bars output to reduce the amount of generated text output.
Disabling progress bars removes the following lines from output on Continuous Integration servers:
Processing source code files: 0/5678
Progress bar display will be automatically disabled with or without this option when either
CONTINUOUS_INTEGRATION environment variables are set to
For example, there is no need to enable this option manually on Travis CI just to hide progress bars.
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:
progress. Default is
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.
Run Initial Tests process with additional php options. For example with
-d zend_extension=xdebug.so which will run Xebug 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 zend_extension=xdebug.so"
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.