94

Where can I find the specification of JUnit's XML output. My goal is to write a UnitTest++ XML reporter which produced JUnit like output.

See: "Unable to get hudson to parse JUnit test output XML" and "Hudson, C++ and UnitTest++"

4
  • Could you provide some more information, which output do you mean? Probably an example or instruction how to get such an ouput? Thanks!
    – guerda
    Jan 16, 2009 at 6:59
  • Is it for JUnit 4.x? Which TestRunner do you use?
    – guerda
    May 6, 2009 at 7:55
  • if you had the time to write an XML reporter for UnitTest++, I would be interested if you can share it.
    – Vincent
    Nov 8, 2010 at 16:57
  • 30
    I'm surprised to hear that seeking a specification or standard "tend[s] to attract opinionated answers ...". I can understand why discussion of a spec or standard would create such problems, but a spec itself is simply a concrete fact. Either it exists or it doesn't, and an answerer either knows where it exists or not. Given the importance of specs and standards in helping modern software -- the most complex artifacts people have ever built -- interoperate, I think that the SO guidelines should be altered to allow these types of questions.
    – Arthur
    Oct 19, 2016 at 17:40

5 Answers 5

56

You can find an XSD based on the code in Apache Ant 1.8.2 at https://github.com/windyroad/JUnit-Schema

3
  • 7
    See my commentary at windyroad.zendesk.com/entries/… for pieces missing from this XSD.
    – Reinderien
    Apr 23, 2014 at 20:14
  • 1
    bringing the comment on-site, Reinderien found out that these are seems to be missing: /testsuites/testsuite/@skipped, /testsuites/testsuite/testcase/skipped, /testsuites/testsuite/error, /testsuites/testsuite/failure, /testsuites/testsuite/system-err, after readthrough of XMLJUnitResultFormatter.java, XMLResultAggregator.java, XMLConstants.java at svn.apache.org/repos/asf/ant/core/trunk/src/main/org/apache/…
    – n611x007
    Apr 22, 2015 at 13:24
  • 2
    @naxa, I believe those nodes were added after Apache Ant 1.8.2. I recall being very thorough at the time (back at the begging of 2011). I've just moved the XSD to github and switched the license to the Apache License version 2.0. Feel free to fork and update.
    – Tom Howard
    Apr 27, 2015 at 9:52
13

The xml output is not generated by JUnit (at least, not the junit.jar), but by the junit ant task.
The relevant class is org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter.

3
9

I found some informal spec at http://ant.1045680.n5.nabble.com/schema-for-junit-xml-output-td1375274.html

1
  • 2
    yes, I've landed on that page too, but it's not complete. in extending RUnit (unit testing for R) so that it produces output compatible with Hudson, I ended up producing one "testsuites", there a list of "testsuite" and in these all "testcase". I still don't know how to mark deactivated tests.
    – mariotomo
    Sep 24, 2010 at 13:54
7

As others have mentioned the xml is handled by ANT not jUnit

Here's the best spec I've seen. From this post

-6

I can only give you an general information.

In the sourcecode of JUnit, you will find your information. If you provide some more information, I can help you further. My personal hint for finding your specification would be junit.framework.TestResult.

Good luck!

1
  • 2
    JUnit knows nothing at all about this format. It's generated by ant. It's a bit of a funny business. Jun 14, 2011 at 14:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.