Friday, 6 March 2015

How to create Jenins CI compatible JUnit report XML

Currently I use Jenkins version 1.6x. For the most curious here is an example XML that shows the structure. For those of the visual types there will be some treats after the code.




Ok now, let's see how these tags translate on the report UI.

First we are seeing failed results.



These are either failures or errors.


When looking at the test report main page, we'll see a minimal summary.


Let's look at a failed test now, where we also supplied and output (e.g. STDOUT).


Let's see how this is put together in code. I have also pointed out the components of the heading.


The heading can have another component too:



Errors are also failed tests, but you really should add an extra error output to the report for them:



And finally the passed code is a plain entry. Still, you may supply a normal output to it via the element.



Conclusion

The source XSD file I used to figure out how the JUnit XML should look like can be found here. Although the XSD suggests a far more feature rich XML structure, only a minor portion of that information is used by Jenkins. :(