About Jenkins JUnit XML Format

28,392

Solution 1

I think that information will be automatically computed by Jenkins. If not - don't bother adding it, it won't be displayed anyway.

Here's a useful tip on how to debug this sort of thing: create a job (let's name it jUnitReport) that "touches" a file (let's call it jUnit.xml) in a shell/batch build step; add 'Publish JUnit test resul report' and specify jUnit.xml in 'Test report XMLs' edit box. Run the job once - that will create its workspace. Now place valid jUnit.xml that you want to test in the workspace. Run the job again and examine how test results look.

It is important not to remove the 'touch' step - otherwise Jenkins will think of the test results as stale and fail the build.

You can now play with jUnit.xml without running actual tests and examine how it affects results Jenkins displays.

Solution 2

I have done this in python. So I can tell you in python. import a package called xmlrunner

import xmlrunner

class ABC(unittest.TestCase)
asserts/tests..
...

if __name__ == "__main__":
   suite = unittest.TestLoader().loadTestsFromTestCase(ABC)
   xmlrunner.XMLTestRunner().run(suite)

Now in your jenkins machine go to Post-build Actions Click on the check box next to Publish JUnit test result report and provide the path name to the xml file. (**/test.xml)

you should save-build and the check your detailed results. Hope it helps.

Solution 3

Not sure if you found what you are looking for. But the following sample works for me.

<testsuites tests="38" failures="2" disabled="0" errors="0" time="10.898" name="AllTests">
    <!-- Add test suite and other stuff here-->
</testsuites>

Here is what Jenkins supports. Not sure if it is the same for Hudson. 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

Share:
28,392
GJ.
Author by

GJ.

Updated on July 11, 2020

Comments

  • GJ.
    GJ. almost 4 years

    I'm working on a script that generates test results in JUnit XML format that Jenkins accepts.

    I read through some answers in StackOverFlow about this topic: JUnit XML format specification that Hudson supports and Spec. for JUnit XML Output but none of these talks about the detail of the "testsuites" attributes or options.

    I want to show the total number of "testcase", total number of failed "testcase" and total number of skipped "testcase" from all the "testsuite" under the "testsuites".

    ie <testsuites *something to add here to include the info demanded*>...</testsuites>

    Is there a way to achieve that?

    Any help will be greatly appreciated!