Open ndench opened 9 months ago
I can confirm that Pest 2.x is unusable with Infection. Before merging a proper JUnit logging it was not failing on CI, but also was not reporting any mutants, you were always getting the 100% MSI.
Hey @ndench
Can you confirm that it works if you manipulate the coverage XML to match the junit output
<covered by="Tests\CalculatorTest::it adds"/>
Hey @nuernbergerA, yes I can confirm that changing the coverage XML manually makes infection work.
ie. I made the following change to coverage-xml/index.xml
<tests>
- <test name="P\Tests\CalculatorTest::__pest_evaluable_it_adds" size="unknown" status="success"/>
+ <test name="Tests\CalculatorTest::it adds" size="unknown" status="success"/>
- <test name="P\Tests\CalculatorTest::__pest_evaluable_it_subtracts" size="unknown" status="success"/>
+ <test name="Tests\CalculatorTest::it subtracts" size="unknown" status="success"/>
</tests>
And the following change to coverage-xml/Calculator.php.xml
<coverage>
<line nr="9">
- <covered by="P\Tests\CalculatorTest::__pest_evaluable_it_adds"/>
+ <covered by="Tests\CalculatorTest::it adds"/>
</line>
<line nr="14">
- <covered by="P\Tests\CalculatorTest::__pest_evaluable_it_subtracts"/>
+ <covered by="Tests\CalculatorTest::it subtracts"/>
</line>
</coverage>
Is anything blocking the junit output from changing back? If not, it should be relatively simple to 'rollback' the changes to the junit output right?
Just rolling back isn't the right thing because then the location is messed up again.
I will open a PR that will output a working XML for both scenarios.
@ndench @michael-rubel @Sjustein
please check the #1145 if anything works now
Infection does indeed understand this format again, but it always reports a 100% mutation score. I'm not sure if this is an issue specific to your implementation though, it might just be something with infection. Thanks for the great speed!
What Happened
I use the junit and xml coverage output from Pest for Infection. This has been working until Pest 2.32.0 where junit support was added to 2.x. Before this, I believe that PHPUnit was outputting it's own Junit output which somehow was working fine.
The previous junit.xml format
```xmlThe current junit.xml format
```xmlThe new format is much better, however I believe the xml coverage report also needs to be updated, as it now references tests that do not exist
<covered by="P\Tests\CalculatorTest::__pest_evaluable_it_adds"/>
The coverage-xml report
```xmlThis causes infection to fail because it cannot find the necessary tests:
How to Reproduce
Using reproducer
I created a small reproducer: https://github.com/ndench/pest-junit-xml-conflicts To use this, you'll need:
git
docker compose
make
git clone git@github.com:ndench/pest-junit-xml-conflicts.git
make vendor
make test
Now you can see the junit output at
build/junit.xml
and the coverage XML output atbuild/coverage-xml
. You can also runmake infect
to see the error from infection.Switch to Pest 2.31
make pest-2.31
make test
Now you can see the previous
build/junit.xml
output, and also runmake infect
to see infection pass.You can also use
make pest-2.32
which will install2.32.0
to see the first version which introduced the change. Andmake pest-latest
to get back to the latest version.From scratch
It's also very easy to do this yourself from a blank project.
--log-junit
and--coverage-xml
flagsSample Repository
https://github.com/ndench/pest-junit-xml-conflicts
Pest Version
2.32.0-2.33.6
PHP Version
8.2.13
Operation System
Linux
Notes
By manually editing the
vendor/pestphp/pest/src/Bootstrappers/BootOverrides.php
, I can make Pest use the old PHPUnit format to workaround this issue temporarily. But I don't believe this is a solution to the problem on it's own.