Spec. for JUnit XML Output [closed]
Asked Answered
S

5

95

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++"

Seniority answered 14/1, 2009 at 10:33 Comment(5)
Could you provide some more information, which output do you mean? Probably an example or instruction how to get such an ouput? Thanks!Cistaceous
Is it for JUnit 4.x? Which TestRunner do you use?Cistaceous
if you had the time to write an XML reporter for UnitTest++, I would be interested if you can share it.Borroff
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.Teage
Whoever closed that ticket didn't understand the question, yet decided to take inappropriate actions which lowered again the quality of this website content, even though that probably wasn't his goal.Bice
P
57

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

Platypus answered 7/2, 2011 at 20:17 Comment(4)
See my commentary at windyroad.zendesk.com/entries/… for pieces missing from this XSD.Oak
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/…Pigment
@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.Platypus
This was a huge help getting my custom C# testing application to output results in a way that Azure Devops pipelines could understand.Canebrake
C
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.

Conduit answered 31/8, 2009 at 10:8 Comment(3)
This is great. I'd love to see real documentation or a real spec, but otherwise there's nothing more authoritative than the source.Kocher
Interpretation of that source also requires reading svn.apache.org/repos/asf/ant/core/trunk/src/main/org/apache/… .Oak
Also read svn.apache.org/repos/asf/ant/core/trunk/src/main/org/apache/… since it's the source of the package and ID attributes.Oak
D
9

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

Detective answered 5/5, 2009 at 14:44 Comment(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.Ferroelectric
@Ferroelectric - under junit.org/junit5/docs/current/user-guide/… it states "event-based format [is] specified" by github.com/ota4j-team/open-test-reporting. See Core Spec at: github.com/ota4j-team/open-test-reporting/blob/…Amby
D
7

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

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

Denominator answered 1/5, 2010 at 4:16 Comment(0)
C
-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!

Cistaceous answered 19/1, 2009 at 11:15 Comment(1)
JUnit knows nothing at all about this format. It's generated by ant. It's a bit of a funny business.Grimaud

© 2022 - 2024 — McMap. All rights reserved.