Using with CI

CLI options

We like the idea of using Infection together with other code quality tools in your Continuous Integration (CI) server.

For this purpose, there are two available options:

Metrics:
Mutation Score Indicator (MSI): 47%
Mutation Code Coverage: 67%
Covered Code MSI: 70%

The first option --min-msi allows to control your Mutation Score Indicator. As soon as the actual MSI value is below than the value you provided by this option your build will fail.

Example of usage in CI server:

./infection.phar --min-msi=48 --threads=4

This example means that if you get MSI 47%, the build will be failed. This forces you to write more tests with each commit.

The second option --min-covered-msi allows to control Covered Code MSI.

As soon as the actual Covered Code MSI value is below than the value you provided by this option your build will fail.

Example of usage in CI server:

./infection.phar --min-covered-msi=70 --threads=4

This forces you to write more effective tests.

Both these options can be used together. As soon as one of them is failed - the build will also be failed.

Example:

./infection.phar --min-msi=48 --min-covered-msi=70 --threads=4

Using with Travis

The simplest .travis.yml config to integrate Infection with Travis is:

before_script:
- wget https://github.com/infection/infection/releases/download/0.29.0/infection.phar
- wget https://github.com/infection/infection/releases/download/0.29.0/infection.phar.asc
- gpg --recv-keys C6D76C329EBADE2FB9C458CFC5095986493B4AA0
- gpg --with-fingerprint --verify infection.phar.asc infection.phar
- chmod +x infection.phar

script:
- ./infection.phar --min-msi=48 --threads=4

Read more about how to add a Mutation Badge to your Github Project

Infection MSI