About Jenkins JUnit XML Format

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

I read some answers at StackOverFlow about this topic: JUnit XML format specification supported by Hudson and Spec. for JUnit XML Output , but none of this talk about the details of the attributes or "testsuites" options.

I want to show the total number of "testcase", the total number of failed "test files" and the total number of missing "test files" from all "testsuites" under "testuites".

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

Is there any way to achieve this?

Any help would be greatly appreciated!

+7
source share
4 answers

I think the information will be automatically calculated by Jenkins. If not, do not add it, it will not be displayed in any case.

Here is a good tip on how to debug such things: create a task (let it be called jUnitReport) that "touches" the file (let it be called jUnit.xml) at the shell / batch assembly stage; add "Publish JUnit Retest Report" and specify jUnit.xml in the "Edit XML Test Report Data" field. Running the task once - this will create a workspace. Now put the actual jUnit.xml that you want to test in the workspace. Run the job again and check how the test results look.

It is important not to delete the β€œtouch” step, otherwise Jenkins will consider the test results obsolete and not complete the assembly.

Now you can play with jUnit.xml without performing real tests and learn how this affects the results displayed by Jenkins.

+3
source

I did it in python. Therefore, 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" Check the Publish JUnit Test Results Report box and specify the name of the path to the XML file. (** / test.xml)

You must save-build and check your detailed results. Hope this helps.

0
source

I am looking for similar things, and it is basically impossible to use the default junit plugin, it does not parse this information.

You can check the source code https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/tasks/junit/SuiteResult.java#L125 for this plugin.

You can unlock the junit plugin and extend it.

0
source

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> 

This is what Jenkins supports. Not sure if this 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

0
source

All Articles