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 reporter format? #92

Closed
mattaylor opened this issue May 21, 2014 · 17 comments
Closed

junit reporter format? #92

mattaylor opened this issue May 21, 2014 · 17 comments
Labels

Comments

@mattaylor
Copy link
Contributor

Any chance of adding support for custom templates for rendering test reports? A Junit test reporter would be particularly usefull for example to allow jenkins and similar CI tools process and render test results effectively .

@prakhar1989
Copy link
Contributor

Hi @mattaylor, this sounds like a great idea. We'll work on this and release an update. Will keep you posted! 👍

@patimen
Copy link

patimen commented Jun 18, 2014

+1 on this!

@mattaylor
Copy link
Contributor Author

FYI heres a brain dead livescript module to convert the json output to xunit...

report = require './testReport.json'
xml = '<?xml version="1.0" encoding="UTF-8"?>'
for suite in report.results
   xml += "<testsuite name='#{suite.name}'>"
   for test, count of suite.testPassFailCounts then xml += "<testcase label='#test' failures=#{count.fail} />"
   xml += "</testsuite>"
console.log xml

@morozgrafix
Copy link

+1 on junit/xunit reporter to be built into newman

@nbalsamo
Copy link

This would be awesome to have junit/xunit built in.

@jimthedev
Copy link
Contributor

This would be fantastic since most CI tools can easily parse xunit style reporting.

@jaetask
Copy link

jaetask commented Sep 11, 2014

+1 one this. Any update? would be very nice to integrate with jenkins

@jxf86
Copy link

jxf86 commented Oct 1, 2014

+1

@abhijitkane
Copy link
Member

Newman 1.2.0 now supports junit-style output for tests. (Thanks @pal-thomassen)

Sample response:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
    <testsuite name="TestRequest" id="609a5233-6542-c2ed-b308-446101ac693d" timestamp="2014-12-02T07:06:21.186Z" time="51.50 ms" totalTime="103 ms" tests="4" iterations="2">
        <testcase name="SampleTest1" successes="2" failures="0" />
        <testcase name="SampleTest2" successes="2" failures="0" />
        <testcase name="SampleTest3" successes="1" failures="1" />
        <testcase name="SampleTest4" successes="0" failures="2" />
    </testsuite>
</testsuites>

@sciutand
Copy link

The syntax of the report file does not seem to correspond to the junit supported syntax found at http://llg.cubic.org/docs/junit/

successes is not recognised.
failures property should live in the testsuite not testcase. Just tested with Jenkins junit plugin and success es/failures are not reported correctly because of malformed syntax

@Torquem
Copy link

Torquem commented Dec 23, 2014

Jenkins seems to expect the optional failure inside the testcase.


<testcase ...>
    <failure message="I so fail" type="epic" />
</testcase>

@abhijitkane
Copy link
Member

A <testsuite> element corresponds to a request.
A single request can have multiple tests (represented by the tests[] array).
Each test corresponds to a <testcase>.

In case of multiple iterations, each test is run multiple times. So having a single <failure> element inside the <testcase> isn't suitable.

The next newman version (v1.2.5) will have successes and failures attributes in the <testsuite> element, that'll aggregate the counts in the constituent <testcase> elements

@sbutlerjr
Copy link

just tested 1.2.6. successes and failures are in the testsute and testcase node. The testsuite node is aggregating the test case node. However Jenkins still isn't parsing that format it seems. Jenkins reads that junit output, it shows them all as successful, even when there are failures in the junit xml.

@sbutlerjr
Copy link

To add some additional detail to this, the Jenkins xsd for jUnit is located here: https://svn.jenkins-ci.org/trunk/hudson/dtkit/dtkit-format/dtkit-junit-model/src/main/resources/com/thalesgroup/dtkit/junit/model/xsd/junit-4.xsd

So, an example file would like like below, if there were an error. Seems like the current version that newman creates is missing the failures sumed up in the testsuites node, and its also missing the failure node within the testcase (if it had an error). For example:

<testsuite failures="1" tests="3">
    <testcase classname="foo1" name="ASuccessfulTest"/>
    <testcase classname="foo2" name="AnotherSuccessfulTest"/>
    <testcase classname="foo3" name="AFailingTest" failures="1">
        <failure type="NotEnoughFoo"> details about failure </failure>
    </testcase>
</testsuite>

@rclayton-the-terrible
Copy link

+10

cdonahue added a commit to iVantage/Newman that referenced this issue Feb 13, 2015
XML output updated to adhere to the Jenkins JUnit xsd document as posted
below, in response to issue postmanlabs#92.

While we only list the child failure once per test case, the message
notes how many of the iterations actually failed. Using the XML output
as generated by these changes allows the "failure" count to display in
Jenkins test output and trend charts.

https://svn.jenkins-ci.org/trunk/hudson/dtkit/dtkit-format/dtkit-junit-model/src/main/resources/com/thalesgroup/dtkit/junit/model/xsd/junit-4.xsd
@sbutlerjr
Copy link

Tested the patch from commit #184 and it worked. Thanks!

@Ernesto-Maserati-CH
Copy link

I don't understand the latest state of this issue.
Is it now built into Newman?
Or does it to be converted with a custom script by each guy who wants a xUnit report?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests