-
-
Notifications
You must be signed in to change notification settings - Fork 318
fix(test-runner-junit-reporter): standardize JUnit format #2073
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
base: master
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 80c0bbe The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
165898b
to
7ea8e61
Compare
|
53b927f
to
2f952ac
Compare
There is no single standard XML format for JUnit output, sadly. However there are some XML Schema Definition (XSD) files which are circulated defining a couple of schemas which Jenkins plugins etc. know about and can validate. This change brings the test-runner-junit-reporter output into conformance with one, `@jenkinssci/xunit-plugin::junit-10.xsd`, which it seemed "closest to". (XSD permits `<testsuites>` tags and each individual `<testsuite>` has an `id` attribute and a `skipped` count, but no `package` attribute, like the foregoing junit-reporter output.) To make this change requires three semantic changes: - `junit-10.xsd` does not permit the `file` attribute on `<testcase>`. This is no great loss of information, as it is recapitulated a level above on the `<testsuite>`. - The requested `file` attribute is now on `<testsuite>` where the schema says it's permissible. - After aggregating `results.reduce(addSuiteTime, 0)` this change has to perform a `Number.prototype.toFixed()` reduction in precision to match the XSD. This change is bubbled up into the data types, which store the number as a `string` now. Fixes: modernweb-dev#2072
2f952ac
to
80c0bbe
Compare
Change scope: I guess I considered it a fix-level change but since the reporter is v0.x.x that would put it as a patch change. We could make it a minor change if you prefer, bumping to 0.6.0 rather than 0.5.1 -- put that into the new version of the commit Does this break CI?: If it did I'd personally consider it an error in the CI tool, CI tools should not break if nonstandard fields are not there, since the vast vast majority of junit-xml-returning packages won't produce a But in the particular case you are looking at, this line says: testcase._attributes.file || (testsuite._attributes !== undefined ? testsuite._attributes.file : null), so if the "file" does not exist on the testcase it'll look one level higher on the testsuite. I added a Can this be made opt-in: I would push back on that but I can do it if you think it's a release blocker. Again if I just google search "example junit test xml" it's not there, if I'm looking at the junit5 legacy XmlReportWriter there's no file fields at all. In |
I'd need more time to confirm what this format required to continue to support Circle CI the way that it does, but these other formatters also support Circle CI, like these, so I'd take a comparison to 1 or 2 of those as a "this will work test". I likely don't have time this week, so @crdrost if you were able to do a quick compare and make sure we're not cutting off the nose, as it were, I'm not opposed to just moving away from this data point in the name of conformity... hard to get a full coverage of CI tools this way, but if GH Action is happy (@bennypowers's tool of choice here) and CircleCi is happy (my tool of choice here), then we're all happy 😉 |
I was able to look up some XML examples for the various frameworks mentioned from there and here's a quick compatibility table:
As you can see, most frameworks don't include Could also, as #2072 mentions, think about making the thing compliant with the PHPUnit schema, this change just seemed easier. Could also just omit the testsuite |
I'm interested in this as well @crdrost. Can we resurrect this PR? Looks like there are conflicts to be resolved. @Westbrook did @crdrost's last comment address your request for comparison to other tools? |
Bumping as I would also be interested in this change. @Westbrook (or maybe @bashmish @thepassle seem like more recent maintainers) do you all have any concerns with this PR and comparison that @crdrost did? I'd also be happy to help update this PR or create a new to resolve the conflicts that have popped up since this was last updated if needed! |
There is no single standard XML format for JUnit output, sadly. However there are some XML Schema Definition (XSD) files which are circulated defining a couple of schemas which Jenkins plugins etc. know about and can validate. This change brings the test-runner-junit-reporter output into conformance with one,
@jenkinssci/xunit-plugin::junit-10.xsd
, which it seemed "closest to". (XSD permits<testsuites>
tags and each individual<testsuite>
has anid
attribute and askipped
count, but nopackage
attribute, like the foregoing junit-reporter output.)To make this change requires two semantic changes:
junit-10.xsd
does not permit thefile
attribute on<testcase>
. This is no great loss of information, as it is recapitulated a level above on the<testsuite>
.After aggregating
results.reduce(addSuiteTime, 0)
this change has to perform aNumber.prototype.toFixed()
reduction in precision to match the XSD. This change is bubbled up into the data types, which store the number as astring
now.