- Guide
- Playground
- GitHub
-
Ecosystem
Help
Resource Lists
Recent Posts
- What's new in Infection 0.26.0
- 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.18.0
Oct 17, 2020
Release: https://github.com/infection/infection/releases/tag/0.18.0
New features and enhancements
Exclude mutations matching the source code by Regular Expression
You may want to exclude mutations to the code that, if mutated, has little-to-no impact, or, alternatively, sometimes isn’t worth testing the result of - for example calls to a logging function.
If your codebase has lots of logging, this can generate many unwanted mutants and will greatly slow down the mutation test run.
Consider these examples:
- $this->logger->error($message, /* context */ ['user' => $user]); |
- Assert::numeric($string); |
To avoid them, you can ignore mutations by regular expression, matching the source code:
{ |
Or just per Mutator:
{ |
global-ignoreSourceCodeByRegex
allows to apply the ignoreSourceCodeByRegex
setting to all mutators & profiles registered and works similar to global-ignore
setting.
Read more about
ignore
andignoreSourceCodeByRegex
settings
Exact matching:
{ |
Ignore any mutants with particular method name, e.g.:
- public function methodCall() { |
- $this->methodCall(); |
with the following config:
{ |
Do not add any delimiters (like /
) to the regular expression: we are adding and escaping them for you.
Allow fractional values for timeout
Allows fractional values for timeout. For example: half a second.
infection.json
:
{ |
Partial PHPUnit 9.3 support
Infection is routinely tested with and using the most recent version of PHPUnit. The only caveat is the still missing support for the new schema. Therefore, to use Infection with recent versions of PHPUnit one should avoid upgrading the configurations, and list a path to the old schema in the configuration like so:
<phpunit |
Using old schema is enough to get Infection running with PHPUnit 9.3 and 9.4.
New Mutators
SharedCaseRemoval
mutator
Code like this:
switch ($value) { |
Creates the following mutants:
switch ($value) { |
switch ($value) { |
switch ($value) { |
This mutator removes only shared cases because there is no way to see they are missing tests by looking at the code coverage.
Enjoy!