- What's new in Infection 0.25.0
- What's new in Infection 0.24.0
- What's new in Infection 0.23.0
- What's new in Infection 0.21.0
- What's new in Infection 0.20.0
- What's new in Infection 0.19.0
- What's new in Infection 0.18.0
- 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.16.0
Mar 28, 2020
- Infection now requires PHP 7.3.12+. If you can’t upgrade for some reason upgrade, don’t worry, you can still use previous versions.
- We had a bug with the config file loading order. Instead of trying to load the file
infection.jsonand if not found, try to load
infection.json.dist, it was doing this in a reverse order, stopping at
infection.json.dist. If you have both
infection.json.dist, please note that the first will be used like it should, unlike before.
Typically Infection first executes your test suite without any modification to ensure it passes. This is so even if you provide needed coverage reports, with only difference in that Infection will not attempt to generate it again from this test run.
However, since many may already run the tests in another context, for example to retrieve a specific coverage format, requiring to run the test suite another time may be a slow and redundant step. For this reason, the
--skip-initial-tests option has been added. Note that to be able to use this option, you must provide the code coverage with the
Note that it is extremely important that you ensure the test suite is passing and the coverage used up to date. Otherwise some mutations might be incorrectly caught or a coverage-related error thrown in the middle of the mutation run.
In 0.15.x and earlier Infection was entirely sequential in its preparation steps. It collected source files as configured, parsed all and every coverage report, prepared every single mutation, and only then went to business. This lead to some undesired consequences for larger projects. Namely, parsing a lot of coverage reports at once required much more memory than available on a typical developer or CI machine.
As of 0.16 Infection would still behave about the same by default, but there’s another mode of operation, toggled by specifying
--no-progress option. Which option enables Infection to stream coverage reports right into mutations, parsing coverage reports and files one by one as needed, while also enabling Infection to leverage poll gaps between mutated processes to do additional work. Therefore it is important to note that this new process works best with the
--threads options, e.g. as in
There’s a slight downside: because Infection won’t buffer and count every mutation before trying them, in this mode Infection won’t report in real-time the remaining number of mutations to try. This downside is unfortunate, but for CI usage it should not be a cause of concerns.
There were other improvements performance wise:
- The lookup and sorting of the tests have been optimized. After creating a mutation, Infection looks up which tests to execute for it, and orders those tests from fastest to slowest. Since this operation is done for each mutation, this is a very hot path in Infection. The lookup process and the sorting strategy have been adjusted and optimized for different use cases in order to speed up the process. Although these changes offer only minor improvements for smaller projects, they may have a measurable effect on larger projects.
- Previously we required a
MutantProcessto record the results in order to log it in the different log files. This was an easy choice because this object could provide all the necessary information. However, in the case of mutations not executed by the tests, this translated into unnecessary operations: creating the process and dumping the framework adapter configuration. As a result, we decoupled the logged results from
MutantProcess, allowing us to filter out those non-covered mutations earlier in the process while still being able to log them.
As the support for more test frameworks is being added, a number of problem surfaced (you can read a more detailed explanation as of why in this RFC). To palliate to this, we decided to split some parts of Infection such as the
Codeception test framework adapters info different packages.
You can read a very detailed explanation about why was it needed in this RFC.
In a nutshell, this is useful both for the end user and for maintainers:
- you will not download not needed code if you don’t use those test frameworks when installing Infection as a Composer package which also allows to reduce the risk of package conflicts
- you will not need to upgrade Infection for patches or improvements made on the test framework adapters that you don’t use
- Clearer test framework adapters dependencies and requirements
To ensure this change does not affect the user-experience of those using other test frameworks than PHPUnit, Infection will be able to automatically pick up that you are missing the test framework adapter package and propose you to install it for you.
List of new packages:
infection/abstract-testframework-adapter- interfaces for any testframework adapter
infection/extension-installer- autodiscovery of installed adapters. No need to add them to
infection.json, just install a Composer package and you are done. Inspired by PHPStan and Psalm plugin system.
infection/include-interceptor- Stream Wrapper. Allows to replace included (autoloaded) file with another one (magic that replaces your code with a mutated one)
It is possible to create a badge displaying your mutation score (check here for more details), however this feature was limited to Travis CI only.
Feel free to request an additional integration there if the list of currently supported continuous-integration servers does not contain a service you require.
Read more about how to setup Mutation Badge
Infection allows adding a configuration to ignore some parts of your code, such as a class, a method or a specific line for a given mutator. For example with:
You might however find yourself in the situation where you want to do this for all mutators. If you only have the
@default profile enabled, this is a simple task. But if you have several mutators listed, you are out of luck and will find yourself having to do a very repetitive, error prone task which is also non-trivial to keep up to date.
In 0.16.x, we are introducing the
global-ignore setting which allows to define an
ignore setting which will be added to all mutators. For example:
Will result in all mutators referenced by
@default to have the following
TrueValue will have:
While this is not the recommended way
*, it is possible to use the options
--min-covered-msi options to force a certain threshold (the Infection process will exit with the error code
1 if one of those is not reached). When using Infection with those, Infection would also now display a recommendation to increase this threshold when the score is above the configured threshold:
! [NOTE] The MSI is 2.5787422095418% percent points over the required MSI.
*: The MSI score is but a metric like another. The interesting part is not necessarily the score but which mutations escaped and whether or not those should be caught. Moreover if you are using Infection in an incremental way, i.e. running it only the changed files, this metric will drastically vary from a change to another depending of how testing this part is making it unsuitable for this use case.
It’s now possible to use Cest files (Codeception Tests) with Infection. Due to how this type of tests work, it was not possible to generate a correct JUnit report for them.
Now they are fully supported