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

Junit logger produces report which Jenxins xunit-plugin considers invalid. #3913

Closed
bdsl opened this issue Oct 28, 2019 · 10 comments
Closed
Labels
type/bug Something is broken

Comments

@bdsl
Copy link

bdsl commented Oct 28, 2019

Q A
PHPUnit version 8.4.2
PHP version 7.3
Installation Method Composer

Summary

Report generated with --log-junit includes an attribute 'warnings' of element 'testsuite'. According to https://github.com/jenkinsci/xunit-plugin/blob/master/src/main/resources/org/jenkinsci/plugins/xunit/types/phpunit-2.0.xsd#L89 this is not an allowed attribute.

Depending on build config, this can cause a build failure in Jenkins, with a message like the following showing up in the log:

At line 3 of file:/var/lib/jenkins/workspace/myproject/build/logs/report.xml:cvc-complex-type.3.2.2: Attribute 'warnings' is not allowed to appear in element 'testsuite'

However I'm not sure if there is any really authoritative xsd for the junit format available, so potentially this could something to fix in the xunit-plugin instead or as well as fixing here. I have also made a PR to xunit-plugin.

This issue is new in PHPUnit 8.4.2 , apparently introduced in e7b8576 .

Current behavior

report.xml file is generated with line as shown below:
<testsuite name="Test Suite" tests="201" assertions="221" errors="0" warnings="0" failures="0" skipped="0" time="0.498413">

How to reproduce

Run ./bin/phpunit --log-junit report.xml

Expected behavior

report.xml to be generated without the warnings attribute, as in PHPUnit 8.4.1:

<testsuite name="Test Suite" tests="201" assertions="221" errors="0" failures="0" skipped="0" time="0.498413">

@sebastianbergmann
Copy link
Owner

The "X" in "XML" stands for "Extensible". This means, at least IMO, that any consumer of the JUnit XML produced by PHPUnit must ignore attributes it does not handle.

There is no (official) standard for JUnit XML and there is no official XSD for JUnit XML. See #3162 for more details. I am sick and tired of this situation and am strongly thinking about abandoning "JUnit XML" and instead create PHPUnit's XML logfile format for test results.

@sebastianbergmann
Copy link
Owner

CC @celeryclub @DanielRuf

@theseer
Copy link
Collaborator

theseer commented Oct 28, 2019

Technically, we already have that with the PHPUnit coverage xml.

@sebastianbergmann
Copy link
Owner

Yes, we "just" need to make it possible to create a logfile using that format when no code coverage is collected/processed.

@theseer
Copy link
Collaborator

theseer commented Oct 28, 2019

When @localheinz and I are done with the Event subsystem, we can have a look at that :)

@bdsl
Copy link
Author

bdsl commented Oct 28, 2019

Thanks @sebastianbergmann.

For now it looks like our options are:

  1. Untick Post Build Actions / publish xUnit test result report / Stop and set the build to 'failed' status if there are errors when processing a result file in Jenkins job config.
  2. Pin PHPUnit to 8.4.1

@bdsl
Copy link
Author

bdsl commented Nov 5, 2019

The PR to xunit-plugin has been merged, so this should be fixed in a future release of that.

@markdwhite
Copy link

Just a nudge to notify watchers that the xunit-plugin has been updated and this is now working for me using phpunit 8.5.2

@lstrojny
Copy link
Contributor

@sebastianbergmann what do you think about having an integration test against Jenkins XSDs? https://github.com/jenkinsci/xunit-plugin/tree/master/src/main/resources/org/jenkinsci/plugins/xunit/types

@sebastianbergmann
Copy link
Owner

I am tired of "playing catchup" with various "forks" of JUnit XML. Just because the Jenkins CI project has an XSD does not make this XSD official. There is no "official JUnit XML". This has been discussed in #3162, for instance.

To be honest, I would like to eventually deprecate and remove PHPUnit's ability to generate "JUnit XML" logfiles once #4321 has been implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

5 participants