Skip to content
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

Support new standard for reporting test results in XML format #3162

Closed
sebastianbergmann opened this issue Jun 7, 2018 · 23 comments
Closed
Labels
feature/logging Issues related to logging test results type/enhancement A new idea that should be implemented

Comments

@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Jun 7, 2018

ota4j-team/opentest4j#9 (comment)

@sebastianbergmann sebastianbergmann added the type/enhancement A new idea that should be implemented label Jun 7, 2018
@nfalco79
Copy link

The JUnit5 XSD file referenced in #2964 is not by junit. It is a test resource get from jenkins xunit plugin.

@sebastianbergmann sebastianbergmann changed the title Support JUnit 5 XML Support new standard for reporting test results in XML format Jun 13, 2018
@keradus
Copy link
Contributor

keradus commented Jul 15, 2018

ages ago, we found sth like JUnit v10:
https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.12/doc/junit-10.xsd
I believe it was found in Travis repos or somewhere like that

(yeah, no official xsd so far, sadly)


also, after issue title got change, you may be interested in checkstyle (don't worry, it's not about only style, but any tool reporting), also widely used on different CI runners:
https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.12/doc/checkstyle.xsd

@ColinLaws
Copy link

I hope this input is in the right spot or is appropriate for this thread. I have been having issues with using the test output of PHPUnit with systems that support JUnit. Proper JUnit support would be ideal (at least in the scope of my own personal implementation), as I have seen JUnit as a widely accepted test format.

@keradus
Copy link
Contributor

keradus commented Sep 26, 2018

Proper JUnit support would be ideal

issue is that nobody knows how proper support would look alike, as there is no official data scheme for JUnit format

@nfalco79
Copy link

nfalco79 commented Sep 27, 2018

Proper JUnit support would be ideal

issue is that nobody knows how proper support would look alike, as there is no official data scheme for JUnit format

yes and no.
JUnit java library has not define an official schema for XML report. You can choose to follow one of the most supported schemas (maven surefire or junit ant task). Or define you own schema (away from junit) for php (to cover your needs) and ask to support it to reporting CI tools.

@ColinLaws
Copy link

@keradus Forgive me, I'm definitely not the expert when it comes to this. I'm just an end user who consumes PHPUnit and would like to use it in Azure DevOps (and they don't support nested test suites). I wish everyone could agree on an open testing standard, but I don't know if there'd be a way to make it fit everyone's needs given there may be language specific data.

@mindplay-dk
Copy link

JUnit 5 does come with an XSD:

https://github.com/junit-team/junit5/blob/master/platform-tests/src/test/resources/jenkins-junit.xsd

This appears to match most of the third-party XSD's I've been able to find.

Nested testsuite elements? I'm surprised it works - does anything besides PHPUnit emit those?

(Kind of crazy how the entire OS world is using JUnit XML as the de-facto standard, while literally nobody seems to know exactly what it is they supposedly agree on - and we all just go along with it...)

@epdenouden
Copy link
Contributor

epdenouden commented Jan 4, 2019

This appears to match most of the third-party XSD's I've been able to find.

Lovely, that sounds just like the kind of well-described standard to suit a testig framework. 😨
Refactoring the event and logging subsystem is one of my chew toys and I've added the JUnit 5 reference to my reading list. Thanks!

@nfalco79
Copy link

JUnit 5 does come with an XSD:

https://github.com/junit-team/junit5/blob/master/platform-tests/src/test/resources/jenkins-junit.xsd

This appears to match most of the third-party XSD's I've been able to find.

Nested testsuite elements? I'm surprised it works - does anything besides PHPUnit emit those?

(Kind of crazy how the entire OS world is using JUnit XML as the de-facto standard, while literally nobody seems to know exactly what it is they supposedly agree on - and we all just go along with it...)

JUnit does not come with an XSD. That XSD was copy for test purpoise (platform-tests project) by the xunit plugin (read the header of XSD). That file was created by Gregory Boissinot, the original author of jenkins xunit plugin making a sort of mixup of all cases found.

@mindplay-dk
Copy link

mindplay-dk commented Apr 25, 2019

JUnit does not come with an XSD

Well, it's part of the test-suite - so, in my optic, it's part of the specification.

Regardless of where it originated, this is the spec to which the JUnit codebase itself adheres.

Or not?

@epdenouden
Copy link
Contributor

My main concern is before allocating effort: is the standard (XSD or not) stable, at least for now? I'm happy to implement it in PHPUnit if so.

@epdenouden
Copy link
Contributor

epdenouden commented Apr 25, 2019

Well, it's part of the test-suite - so, in my optic, it's part of the specification.

I would agree if and only if the XSD has been included for this purpose. Many test suites also include tests for scenarios that cannot be rolled back because the development community adopted another 'forever beta' thing.

In PHPUnit's own collection there are a few guards for old logger behaviour, which frankly isn't great.

@nfalco79
Copy link

nfalco79 commented Apr 25, 2019

Well, it's part of the test-suite - so, in my optic, it's part of the specification.

Regardless of where it originated, this is the spec to which the JUnit codebase itself adheres.

Or not?

To be considered as a specific it should be explicited in the documentation. Since you had find a test resource this does not mean that it's the official schema documentation. The name of the file jenkins-junit.xsd should be another signal that has nothing to do with it JUnit official schema. You are free to ask to them about if that is an official schema for the JUnit (I would rememeber that till JUnit4 the library does not produce any report in any format JSON or XML or other)

@mindplay-dk
Copy link

Right, I don't disagree, it obviously isn't the official schema, but... there isn't one.

This appears to be the closest thing to be found in their source-repository or anywhere.

@nfalco79
Copy link

nfalco79 commented Apr 25, 2019

but... there isn't one.

The point is that JUnit it's just a library to run test. It does not to produce report so there is not reason to define any standard. Who use JUnit an engine and than produce a report than it can define a standard (that could be also in other format like JSON). For now there are two historical executor widely used: Maven and Ant. Both of them defined an own schema for XML report and they are completely different from one another. This is the reason of this issue, define a PHPUnit standard (without any restriction to JUnit) to fit the PHP needs. But till now I did not see any movement.

@sebastianbergmann
Copy link
Owner Author

sebastianbergmann commented Apr 25, 2019

Maybe we should create our own logging format for PHPUnit. (Yes, I know, https://xkcd.com/927/.)

To some degree this already exists, thanks to @theseer, with the logfiles that are produced using --coverage-xml. The generator for that would need to be refactored (and moved, at least partially, from php-code-coverage to PHPUnit itself) to only optionally include code coverage data.

Or we wait and hope that ota4j-team/opentest4j#9 (comment) leads to something we can adopt.

@mindplay-dk
Copy link

The generator for that would need to be refactored (and moved, at least partially, from php-code-coverage to PHPUnit itself) to only optionally include code coverage data.

What would happen to those of use who use php-code-coverage independently of php-unit?

@sebastianbergmann
Copy link
Owner Author

Thank you for raising this point, @mindplay-dk. This would need to be taken into account.

@staabm
Copy link
Contributor

staabm commented Jan 23, 2020

ages ago, we found sth like JUnit v10:
https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.12/doc/junit-10.xsd
I believe it was found in Travis repos or somewhere like that

(yeah, no official xsd so far, sadly)

also, after issue title got change, you may be interested in checkstyle (don't worry, it's not about only style, but any tool reporting), also widely used on different CI runners:
https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.12/doc/checkstyle.xsd

Having checkstyle support would be great because with that we also easily get github checks annotations via angeneric script which is already compatible with phpstan, psalm and php-cs-fixer (and every other tool able to generate a checkstyle-formatted report)

https://github.com/staabm/annotate-pull-request-from-checkstyle/

@staabm
Copy link
Contributor

staabm commented Jan 23, 2020

@sebastianbergmann would you accept a PR adding checkstyle xml reports?

as you can see from https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.16/src/Report/CheckstyleReporter.php#L35 the implementation would not be complex

@sebastianbergmann
Copy link
Owner Author

No. I do not believe that Checkstyle XML is a good fit for test results.

@staabm
Copy link
Contributor

staabm commented Jan 23, 2020

did you see the checks api result-printer https://github.com/mheap/phpunit-github-actions-printer ?

we could support this kind of feature easily when the report would be generated in checkstyle format (with a general purpose checkstyle to github annotations converter like https://github.com/staabm/annotate-pull-request-from-checkstyle)

@sebastianbergmann
Copy link
Owner Author

Superseded by #4321.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/logging Issues related to logging test results type/enhancement A new idea that should be implemented
Projects
None yet
Development

No branches or pull requests

7 participants