Quantcast

schema for junit xml output

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

schema for junit xml output

Peter Reilly-2
a question that has been asked a number of times on the hudson mailing
list is what
is the schema of tthe xml that junit generates.

I have had a quick look at the code, and noticed that there two related schemas.
1) the xml that <junit> generates
and
2) the xml that <junitreport> uses internally.

Both these formats are used as input to other reporting tools -
including hudson.

(I assume that maven has a similar junit xml report format)

The xml that <junit> generates has a toplevel element of <testsuite> and nested
<properties>, <testcase>, <system-out> and <system-err> elements.

The xml that <junitreport> uses internally has a toploevel element of
<testsuites> and nested
<testsuite> elements. The content of these <testsuite> elements are the same as
the <testsuite> from the task <junit> *except* that it has two extra
attributes - "id" and "package"..

In any case, here is a first attempt at a schema for junit (in relaxng
compact syntax)

junit.rnc:
#----------------------------------------------------------------------------------
start = testsuite

property = element property {
   attribute name {text},
   attribute value {text}
}

properties = element properties {
   property*
}

failure = element failure {
   attribute message {text},
   attribute type {text},
   text
}

testcase = element testcase {
   attribute classname {text},
   attribute name {text},
   attribute time {text},
   failure?
}

testsuite = element testsuite {
   attribute errors {xsd:integer},
   attribute failures {xsd:integer},
   attribute hostname {text},
   attribute name {text},
   attribute tests {xsd:integer},
   attribute time {xsd:double},
   attribute timestamp {xsd:dateTime},
   properties,
   testcase*,
   element system-out {text},
   element system-err {text}
}
#----------------------------------------------------------------------------------


and junitreport.rnc
#----------------------------------------------------------------------------------
include "junit.rnc" {
   start = testsuites
   testsuite = element testsuite {
      attribute errors {xsd:integer},
      attribute failures {xsd:integer},
      attribute hostname {text},
      attribute name {text},
      attribute tests {xsd:integer},
      attribute time {xsd:double},
      attribute timestamp {xsd:dateTime},
      attribute id {text},
      attribute package {text},
      properties,
      testcase*,
      element system-out {text},
      element system-err {text}
   }
}

testsuites = element testsuites {
   testsuite*
}
#----------------------------------------------------------------------------------

Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: schema for junit xml output

Stefan Bodewig
Looks good to me.

Might be worth to add it to src/etc.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: schema for junit xml output

Jesse Glick
In reply to this post by Peter Reilly-2
Peter Reilly wrote:
> In any case, here is a first attempt at a schema for junit (in relaxng
> compact syntax)

If you are going to declare an official schema, I would recommend making <junit> and <junitreport> enforce it at runtime, at least in development builds (or if assertions
are enabled etc.). Otherwise the danger is high that some "little" change in the tasks will in fact cause unintentional schema drift.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: schema for junit xml output

Jesse Glick
In reply to this post by Peter Reilly-2
Peter Reilly wrote:
> a question that has been asked a number of times on the hudson mailing list is what is the schema of the xml that junit generates.

BTW:

https://hudson.dev.java.net/nonav/issues/show_bug.cgi?id=3007


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: schema for junit xml output

Peter Reilly-2
The google-test people are going to to change the output from
<testsuite><testsuite*/></testsuite> to
<testsuites><testsuite*/></testsuites>
(with a command-line switch).

They have some extra attributes, and do not populate some attributes
and elements. but the output is understood by hudson without mod to
hudson.


Peter.


On Wed, Mar 18, 2009 at 3:50 PM, Jesse Glick <[hidden email]> wrote:

> Peter Reilly wrote:
>>
>> a question that has been asked a number of times on the hudson mailing
>> list is what is the schema of the xml that junit generates.
>
> BTW:
>
> https://hudson.dev.java.net/nonav/issues/show_bug.cgi?id=3007
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: schema for junit xml output

Steve Loughran
Peter Reilly wrote:
> The google-test people are going to to change the output from
> <testsuite><testsuite*/></testsuite> to
> <testsuites><testsuite*/></testsuites>
> (with a command-line switch).
>
> They have some extra attributes, and do not populate some attributes
> and elements. but the output is understood by hudson without mod to
> hudson.
>

well, all the tools are one XSLT away from each other.

TestNG has an extended format with for their non-compatible runs, with
explicit skip flags, and I think every text can have a description

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...