newman icon indicating copy to clipboard operation
newman copied to clipboard

junit reporter format?

Open mattaylor opened this issue 12 years ago • 17 comments

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 .

mattaylor avatar May 21 '14 20:05 mattaylor

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

prakhar1989 avatar May 21 '14 20:05 prakhar1989

+1 on this!

patimen avatar Jun 18 '14 19:06 patimen

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

mattaylor avatar Jun 18 '14 19:06 mattaylor

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

morozgrafix avatar Jul 23 '14 23:07 morozgrafix

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

nbalsamo avatar Aug 26 '14 19:08 nbalsamo

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

jimthedev avatar Sep 10 '14 16:09 jimthedev

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

jaetask avatar Sep 11 '14 12:09 jaetask

+1

jxf86 avatar Oct 01 '14 17:10 jxf86

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>

abhijitkane avatar Dec 02 '14 07:12 abhijitkane

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

sciutand avatar Dec 16 '14 22:12 sciutand

Jenkins seems to expect the optional failure inside the testcase.


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

Torquem avatar Dec 23 '14 10:12 Torquem

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

abhijitkane avatar Jan 14 '15 09:01 abhijitkane

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 avatar Jan 20 '15 00:01 sbutlerjr

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>

sbutlerjr avatar Jan 29 '15 20:01 sbutlerjr

+10

rclayton-the-terrible avatar Feb 13 '15 20:02 rclayton-the-terrible

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

sbutlerjr avatar Feb 18 '15 14:02 sbutlerjr

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?

Ernesto-Maserati-CH avatar Jul 19 '17 08:07 Ernesto-Maserati-CH