-
-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Junit support #291
Add Junit support #291
Conversation
This PR is awaiting feedback from @maks-rafalko. <?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="/Users/olivernybroe/Code/pest/tests/Unit/TestSuite.php" tests="1" assertions="2" errors="0" warnings="0" failures="0" skipped="0" time="0.005243">
<testsuite name="P\Tests\Unit\TestSuite" file="/Users/olivernybroe/Code/pest/tests/Unit/TestSuite.php" tests="1" assertions="2" errors="0" warnings="0" failures="0" skipped="0" time="0.005243">
<testcase name="it does not allow to add the same test description twice" class="Tests\Unit\TestSuite" classname="Tests.Unit.TestSuite" file="/Users/olivernybroe/Code/pest/tests/Unit/TestSuite.php" assertions="2" time="0.005243"/>
</testsuite>
</testsuite>
</testsuites>
|
/** | ||
* @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
final class JUnit extends Printer implements TestListener |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of this file is a copy/paste from phpunit, there are very few changes to it. However it was not possible to just make a wrapper class, at least without a lot of reflections on top.
if (TeamCity::isPestTest($test)) { | ||
$testCase->setAttribute('class', $test->getPrintableTestCaseName()); | ||
$testCase->setAttribute('classname', str_replace('\\', '.', $test->getPrintableTestCaseName())); | ||
// @phpstan-ignore-next-line | ||
$testCase->setAttribute('file', $test->__getFileName()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
custom logic
if ($class->hasMethod('__getFileName')) { | ||
$fileName = $class->getMethod('__getFileName')->invoke(null); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
custom logic
@@ -22,10 +22,13 @@ parameters: | |||
- "#Method Pest\\\\Support\\\\Reflection::getParameterClassName\\(\\) has a nullable return type declaration.#" | |||
- | |||
message: '#Call to an undefined method PHPUnit\\Framework\\Test::getName\(\)#' | |||
path: src/TeamCity.php | |||
path: src/Logging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These ignores were needed for both teamcity and junit
@olivernybroe Once this is ready let me know. |
This is brilliant. I tried to use this branch for Infection for my WIP What I did in my branch:
And it works. If someone wants to play with it (that would be great, since I created very basic pest tests), here is how it can be done:
What's next:
I would expect the new Pest release (is it possible to have |
@maks-rafalko Awesome, I'll take this out of draft then as testing it with infection is more something that belongs on infection/infection#1476. I have some big projects which are pest based mostly, however they are closed source so I'll have to do the testing. @nunomaduro This is ready for review now. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Don't forget to make a pull request on the docs. After that, you can release a new version of Pest with this.
checked
It works. |
I am actually not sure what to document in the docs. JUnit option was there already, it was just broken. Do we want to have docs about us supporting infection? |
that's what I had in mind - to create some page in Pest docs about Infection support. But I wanted to do it once support for Pest is merged to master in Infection, so that it's clear how exactly integration should work (I don't expect any changes to the commands above, but still). I can open PR later on pest docs. Or, if you are going to do it yourself, please ping me so we can check everything together. |
@maks-rafalko I have very little experience with mutation testing, so would be awesome if you could write the docs for usage with pest 👍 |
but in this case Infection won't be ready. How I see it:
Or, do you think it can be done differently? Can pest docs be released independently of pest source code? |
@maks-rafalko I think @olivernybroe just meant having you doing a pull request for the docs. ( not actually merge them ). |
Oh, ok. I will do it in the following days, no problem. |
Should we merge this into master? 😄 |
This PR adds support for Junit reporting.
Junit is used by many third party tools to look into the tests.
In this specific instance I want to add Junit so we can have support for infection php as they rely on junit format.
Adding the support for Pest into infection will not be part of pest codebase and this part will @maks-rafalko do for us.