-
Notifications
You must be signed in to change notification settings - Fork 780
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
junitlogger report xml file content not correctly generated #393
Comments
Finally, the I am pondering if the <?xml version="1.0" encoding="UTF-8"?>
<testsuites hostname="localhost"
tests="1" failures="0" errors="0" time="0.515" timestamp="2013-01-16T16:21:17Z">
<testsuite name="http://localhost/yourTestPageUrl" hostname="localhost"
tests="1" failures="0" errors="0" time="0" timestamp="2013-01-16T16:21:17Z">
<testcase name="AccountsView"
tests="3" failures="0" errors="0" time="0" timestamp="2013-01-16T16:21:17Z" />
</testsuite>
</testsuites> Thoughts? |
@lauterry: I'm in the process of rewriting the JUnitLogger already as it does not mesh well with the Composite addon, so feel free to give any other suggestions/feedback by filing additional new issues. @jzaefferer @Krinkle Please make me the owner of this issue, thanks! |
@JamesMGreene Issues can only be assigned to repo collabs. Since assignees should also take care of review and eventual revert/backport/release, I'll oversee this one allowing you to provide a PR, which I'll then review. |
Fair enough, thanks @Krinkle. |
I noticed this issue by giving the test xml report to Jenkins. The displayed report is not correct. Having the following report processed by jenkins display a more correct report 👍
So for Jenkins, I don't know what would be the equivalent to the |
@JamesMGreene : How do you display your generated XML report? What do you use? |
@lauterry Jenkin's XSD for JUnit shows that their However, the |
@lauterry We don't display our XML report, just have a CI build step (not on Jenkins) to parse the resulting XML file to verify there were no failures or errors. |
@lauterry Also: if we did it your way, we would be showing every assertion even if it passed, which is not a behavior that I've ever seen in my [limited] experience with JUnit XML reports. |
Here's an explanation of the end-behavior I'm intending for the JUnitLogger addon — hopefully with actual tests to verify these example results. Report LogicSo, taking a deeper look at the JUnit XSD for Jenkins again, here's the report logic that I've extracted. I've used a bit of JavaScript pseudo-code plus XPath notations to shorten the descriptions of some of the conceptual values, hopefully that it makes sense to everyone: <?xml version="1.0" encoding="UTF-8" ?>
<testsuites
name="{window.location.href || undefined}"
tests="{count(./testsuite)}"
failures="{count(./testsuite[number(@failures) > 0])}"
errors="{count(./testsuite[number(@errors) > 0])}"
time="{sum(./testsuite/@time)}"
>
<testsuite
id="{./position()}"
name="{qunitModuleName || 'default'}"
tests="{count(./testcase)}"
failures="{count(./testcase[@status = 'fail'])}"
errors="{count(./testcase[@status = 'error'])}"
time="{sum(./testcase/@time)}"
timestamp="{startingDateTime as ISO8601}"
package="{qunitCompositeSuiteName || ../@name || undefined}"
hostname="{window.location.host || require('os').hostname() || 'localhost'}"
>
<properties>
<property name="userAgent" value="{window.navigator.userAgent || 'node'}" />
<property name="testFramework" value="QUnit" />
</properties>
<!-- Passed test -->
<testcase
name="{qunitTestName}"
assertions="{count(`QUnit.push` calls)}"
time="{durationInSeconds}"
status="pass"
classname="{../@name}"
/>
<!-- Failed test -->
<testcase
name="{qunitTestName}"
assertions="{count(`QUnit.push` calls)}"
time="{durationInSeconds}"
status="fail"
classname="{../@name}"
>
<failure type="{assertionType}" message="{assertionMessage}" />
</testcase>
<!-- Erred test -->
<testcase
name="{qunitTestName}"
assertions="{count(`QUnit.push` calls)}"
time="{durationInSeconds}"
status="error"
classname="{../@name}"
>
<error type="{errorType}" message="{errorMessage}" />
</testcase>
<system-out>
/* Redirect all `console.*` output (minus `console.error`), perhaps? */
</system-out>
<system-err>
/* Redirect all `console.error` output, perhaps? */
</system-err>
</testsuite>
</testsuites> There are a number of things about this output that differ from my current output (using a proprietary version of the JUnitLogger addon that pre-dates it) which I care enough about to call out:
|
An interesting post trying to dissect Jenkins' display of a JUnit XML report from a black box perspective: http://nelsonwells.net/2012/09/how-jenkins-ci-parses-and-displays-junit-output/ This would suggest that I'll need to revise the attribute values for |
For now, Jenkins junit integration doesn't use a strict mechanism to parse JUnit output but a custom Jenkins implementation. The Jenkins XSD mentioned refers to the xUnit plugin (https://wiki.jenkins-ci.org/display/JENKINS/xUnit+Plugin). |
@gboissinot: I'm well acquainted with XSL but I don't understand your question. You want an XSL stylesheet (yes, I know that's redundant but that's what I call them) to do what? |
The objective is to apply an XSL to transform the current QUnit output to JUnit compatible to JUnit's Jenkins. |
@gboissinot: Ah, I see. I think that's putting the cart before the horse since our data isn't structured appropriately yet and we have instances of missing assertion details during nested suite runs. :) Will Jenkins choke if there are unrecognized attribute nodes (e.g. |
@gboissinot: Also, are you aware of an official JUnit XML spec/XSD/DTD somewhere that I can look at? We just extended the XML we knew of to best suit our needs but we can certainly adhere to a standard if we know what it is. :) |
There is no strict standard in Jenkins for now. In general, in my knowledge, JUnit does not have an XSD. As I said, Jenkins uses a custom implementation. However if you use the previous XSD (mentioned above), Jenkins is able to read it correctly. |
@lauterry : @ mentions are auto-linked :-) and
(fixed it for you) |
Personally, I am thinking that it would make more sense to have a separate JUnitLogger (for whatever current clients) vs. XUnitLogger (for Jenkins). Thoughts? This also fits into the idea I've mentioned before (e.g. in #378, etc.) about making QUnit extensible for custom reporters (like Mocha). |
I'd like to get a JUnit module in place that takes care of generating JUnit-style XML output in JavaScript, with a testsuite, usable both in node and the browser. See also jzaefferer/node-testswarm#8 |
@jzaefferer How would you expect said module to be used? Various test output formats (i.e. JUnit vs. XUnit) generally require some different data that may not be easy to reconcile. As such, this idea makes me think of a generic json2xml converter, which I believe there are already Node.js modules for (though they may not be browser-compliant, i.e. expecting |
Regarding json2xml, I've used https://github.com/estheban/node-json2xml recently. That works, though there is no npm release for the version in master. The published 0.1.1 code is useless. Might make sense to fork that and publish on npm under a new name. Anyway, I hope such a module, as long as it outputs something that Jenkins can use, would abstract enough details that QUnit or node-testswarm or other grunt plugins can use it without worrying about producing valid output. |
Moved to JamesMGreene/qunit-reporter-junit#1. |
Hello
Please assume that I have the following test :
Running junitlogger generate the following xml report :
I expect the testsuite tag to have a name "AccountsView" instead of undefined and I have only one testcase whereas I expect 3. The report content do not seem to be correctly built.
Please correct me if I'm wrong
Best regards
The text was updated successfully, but these errors were encountered: