Date: Fri, 29 Mar 2024 05:07:44 +0000 (UTC) Message-ID: <93275760.10779.1711688864928@catch-kbase-p> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_10778_1512713370.1711688864918" ------=_Part_10778_1512713370.1711688864918 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Duette supports importing results from QTP, RFT, Selenium (HTML format) = and unit testing frameworks.
For unit test frameworks ET supports a number of different formats (Gall= io, JSUnit,JUnit, Microsoft MSTest, Parasoft C++test and PHPUnit). Prior to= being imported, ET transforms each of these formats into the JUnit X= ML results format (a popular Java unit test framework).
If you have bespoke unit testing data that you want to import into Enter= prise Tester, you can create bespoke tooling to transform your results into= JUnit XML format. Once your results are transformed, they can then b= e imported into Duette.
This page documents the JUnit XML format itself.
Here is an example of a JUnit output file, showing a skip and failed res= ult, as well as a single passed result.
<?xml version=3D"1.0" encoding=3D"UTF-8"?> <testsuites> <testsuite name=3D"JUnitXmlReporter" errors=3D"0" tests=3D"0" failure= s=3D"0" time=3D"0" timestamp=3D"2013-05-24T10:23:58" /> <testsuite name=3D"JUnitXmlReporter.constructor" errors=3D"0" skipped= =3D"1" tests=3D"3" failures=3D"1" time=3D"0.006" timestamp=3D"2013-05-24T10= :23:58"> <properties> <property name=3D"java.vendor" value=3D"Sun Microsystems Inc." = /> <property name=3D"compiler.debug" value=3D"on" /> <property name=3D"project.jdk.classpath" value=3D"jdk.classpath= .1.6" /> </properties> <testcase classname=3D"JUnitXmlReporter.constructor" name=3D"shoul= d default path to an empty string" time=3D"0.006"> <failure message=3D"test failure">Assertion failed</failu= re> </testcase> <testcase classname=3D"JUnitXmlReporter.constructor" name=3D"shoul= d default consolidate to true" time=3D"0"> <skipped /> </testcase> <testcase classname=3D"JUnitXmlReporter.constructor" name=3D"shoul= d default useDotNotation to true" time=3D"0" /> </testsuite> </testsuites>
Below is the documented structure of a typical JUnit XML report. Notice = that a report can contain 1 or more test suite. Each test suite has a set o= f properties (recording environment information). Each test suite al= so contains 1 or more test case and each test case will either contain a sk= ipped, failure or error node if the test did not pass. If the test ca= se has passed, then it will not contain any nodes. For more details o= f which attributes are valid for each node please consult the following sec= tion "Schema".
<testsuites> =3D> the aggregated result of all junit t= estfiles <testsuite> =3D> the output from a single TestSuite <properties> =3D> the defined properties at test execution <property> =3D> name/value pair for a single property ... </properties> <error></error> =3D> optional information, in place of a= test case - normally if the tests in the suite could not be found etc. <testcase> =3D> the results from executing a test method <system-out> =3D> data written to System.out during the tes= t run <system-err> =3D> data written to System.err during the tes= t run <skipped/> =3D> test was skipped <failure> =3D> test failed <error> =3D> test encountered an error </testcase> ... </testsuite> ... </testsuites>
The JUnit XML Report output comes from a build tool called Nant, as oppo= sed to the JUnit project itself - thus it can be a little tricky to nail do= wn an official spec for the format, even though it's widely adopted and use= d. There have been a number of attempts to codify the schema, first = off there is an XSD for JUnit:
<?xm= l version=3D"1.0" encoding=3D"UTF-8"?> <xs:schema xmlns:xs=3D"http://www.w3.org/2001/XMLSchema" elementFormDefa= ult=3D"qualified" attributeFormDefault=3D"unqualified"> <xs:annotation> <xs:documentation xml:lang=3D"en">JUnit test result schema for = the Apache Ant JUnit and JUnitReport tasks Copyright =C2=A9 2011, Windy Road Technology Pty. Limited The Apache Ant JUnit XML Schema is distributed under the terms of the GNU L= esser General Public License (LGPL) http://www.gnu.org/licenses/lgpl.html Permission to waive conditions of this license may be requested from Windy = Road Support (http://windyroad.org/support).</xs:documentation> </xs:annotation> <xs:element name=3D"testsuite" type=3D"testsuite" /> <xs:simpleType name=3D"ISO8601_DATETIME_PATTERN"> <xs:restriction base=3D"xs:dateTime"> <xs:pattern value=3D"[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{= 2}:[0-9]{2}" /> </xs:restriction> </xs:simpleType> <xs:element name=3D"testsuites"> <xs:annotation> <xs:documentation xml:lang=3D"en">Contains an aggregation of= testsuite results</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name=3D"testsuite" minOccurs=3D"0" maxOccurs=3D"= unbounded"> <xs:complexType> <xs:complexContent> <xs:extension base=3D"testsuite"> <xs:attribute name=3D"package" type=3D"xs:token"= use=3D"required"> <xs:annotation> <xs:documentation xml:lang=3D"en">Deriv= ed from testsuite/@name in the non-aggregated documents</xs:documentatio= n> </xs:annotation> </xs:attribute> <xs:attribute name=3D"id" type=3D"xs:int" use=3D= "required"> <xs:annotation> <xs:documentation xml:lang=3D"en">Start= s at '0' for the first testsuite and is incremented by 1 for each following= testsuite</xs:documentation> </xs:annotation> </xs:attribute> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name=3D"testsuite"> <xs:annotation> <xs:documentation xml:lang=3D"en">Contains the results of ex= exuting a testsuite</xs:documentation> </xs:annotation> <xs:sequence> <xs:element name=3D"properties"> <xs:annotation> <xs:documentation xml:lang=3D"en">Properties (e.g., en= vironment settings) set during test execution</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name=3D"property" minOccurs=3D"0" maxOccur= s=3D"unbounded"> <xs:complexType> <xs:attribute name=3D"name" use=3D"required"> <xs:simpleType> <xs:restriction base=3D"xs:token"> <xs:minLength value=3D"1" /> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name=3D"value" type=3D"xs:string" = use=3D"required" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name=3D"testcase" minOccurs=3D"0" maxOccurs=3D"unbo= unded"> <xs:complexType> <xs:choice minOccurs=3D"0"> <xs:element name=3D"error"> <xs:annotation> <xs:documentation xml:lang=3D"en">Indicates t= hat the test errored. An errored test is one that had an unanticipated pro= blem. e.g., an unchecked throwable; or a problem with the implementation of= the test. Contains as a text node relevant data for the error, e.g., a sta= ck trace</xs:documentation> </xs:annotation> <xs:complexType> <xs:simpleContent> <xs:extension base=3D"pre-string"> <xs:attribute name=3D"message" type=3D"xs:= string"> <xs:annotation> <xs:documentation xml:lang=3D"en">= ;The error message. e.g., if a java exception is thrown, the return value o= f getMessage()</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name=3D"type" type=3D"xs:str= ing" use=3D"required"> <xs:annotation> <xs:documentation xml:lang=3D"en">= ;The type of error that occured. e.g., if a java execption is thrown the fu= ll class name of the exception.</xs:documentation> </xs:annotation> </xs:attribute> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name=3D"failure"> <xs:annotation> <xs:documentation xml:lang=3D"en">Indicates t= hat the test failed. A failure is a test which the code has explicitly fail= ed by using the mechanisms for that purpose. e.g., via an assertEquals. Con= tains as a text node relevant data for the failure, e.g., a stack trace<= /xs:documentation> </xs:annotation> <xs:complexType> <xs:simpleContent> <xs:extension base=3D"pre-string"> <xs:attribute name=3D"message" type=3D"xs:= string"> <xs:annotation> <xs:documentation xml:lang=3D"en">= ;The message specified in the assert</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name=3D"type" type=3D"xs:str= ing" use=3D"required"> <xs:annotation> <xs:documentation xml:lang=3D"en">= ;The type of the assert.</xs:documentation> </xs:annotation> </xs:attribute> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:choice> <xs:attribute name=3D"name" type=3D"xs:token" use=3D"requ= ired"> <xs:annotation> <xs:documentation xml:lang=3D"en">Name of the te= st method</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name=3D"classname" type=3D"xs:token" use=3D= "required"> <xs:annotation> <xs:documentation xml:lang=3D"en">Full class nam= e for the class the test method is in.</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name=3D"time" type=3D"xs:decimal" use=3D"re= quired"> <xs:annotation> <xs:documentation xml:lang=3D"en">Time taken (in= seconds) to execute the test</xs:documentation> </xs:annotation> </xs:attribute> </xs:complexType> </xs:element> <xs:element name=3D"system-out"> <xs:annotation> <xs:documentation xml:lang=3D"en">Data that was writte= n to standard out while the test was executed</xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base=3D"pre-string"> <xs:whiteSpace value=3D"preserve" /> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name=3D"system-err"> <xs:annotation> <xs:documentation xml:lang=3D"en">Data that was writte= n to standard error while the test was executed</xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base=3D"pre-string"> <xs:whiteSpace value=3D"preserve" /> </xs:restriction> </xs:simpleType> </xs:element> </xs:sequence> <xs:attribute name=3D"name" use=3D"required"> <xs:annotation> <xs:documentation xml:lang=3D"en">Full class name of the = test for non-aggregated testsuite documents. Class name without the package= for aggregated testsuites documents</xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base=3D"xs:token"> <xs:minLength value=3D"1" /> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name=3D"timestamp" type=3D"ISO8601_DATETIME_PATTERN"= use=3D"required"> <xs:annotation> <xs:documentation xml:lang=3D"en">when the test was execu= ted. Timezone may not be specified.</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name=3D"hostname" use=3D"required"> <xs:annotation> <xs:documentation xml:lang=3D"en">Host on which the tests= were executed. 'localhost' should be used if the hostname cannot be determ= ined.</xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base=3D"xs:token"> <xs:minLength value=3D"1" /> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name=3D"tests" type=3D"xs:int" use=3D"required"> <xs:annotation> <xs:documentation xml:lang=3D"en">The total number of tes= ts in the suite</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name=3D"failures" type=3D"xs:int" use=3D"required"&g= t; <xs:annotation> <xs:documentation xml:lang=3D"en">The total number of tes= ts in the suite that failed. A failure is a test which the code has explici= tly failed by using the mechanisms for that purpose. e.g., via an assertEqu= als</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name=3D"errors" type=3D"xs:int" use=3D"required"> <xs:annotation> <xs:documentation xml:lang=3D"en">The total number of tes= ts in the suite that errorrd. An errored test is one that had an unanticipa= ted problem. e.g., an unchecked throwable; or a problem with the implementa= tion of the test.</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name=3D"time" type=3D"xs:decimal" use=3D"required"&g= t; <xs:annotation> <xs:documentation xml:lang=3D"en">Time taken (in seconds)= to execute the tests in the suite</xs:documentation> </xs:annotation> </xs:attribute> </xs:complexType> <xs:simpleType name=3D"pre-string"> <xs:restriction base=3D"xs:string"> <xs:whiteSpace value=3D"preserve" /> </xs:restriction> </xs:simpleType> </xs:schema>
There is also a Relax NG Compact Syntax Schema:
junit.rnc:=20 #--------------------------------------------------------------------------= --------=20 start =3D testsuite=20 property =3D element property {=20 attribute name {text},=20 attribute value {text}=20 }=20 properties =3D element properties {=20 property*=20 }=20 failure =3D element failure {=20 attribute message {text},=20 attribute type {text},=20 text=20 }=20 testcase =3D element testcase {=20 attribute classname {text},=20 attribute name {text},=20 attribute time {text},=20 failure?=20 }=20 testsuite =3D element testsuite {=20 attribute errors {xsd:integer},=20 attribute failures {xsd:integer},=20 attribute hostname {text},=20 attribute name {text},=20 attribute tests {xsd:integer},=20 attribute time {xsd:double},=20 attribute timestamp {xsd:dateTime},=20 properties,=20 testcase*,=20 element system-out {text},=20 element system-err {text}=20 }=20 #--------------------------------------------------------------------------= --------=20 and junitreport.rnc=20 #--------------------------------------------------------------------------= --------=20 include "junit.rnc" {=20 start =3D testsuites=20 testsuite =3D element testsuite {=20 attribute errors {xsd:integer},=20 attribute failures {xsd:integer},=20 attribute hostname {text},=20 attribute name {text},=20 attribute tests {xsd:integer},=20 attribute time {xsd:double},=20 attribute timestamp {xsd:dateTime},=20 attribute id {text},=20 attribute package {text},=20 properties,=20 testcase*,=20 element system-out {text},=20 element system-err {text}=20 }=20 }=20 testsuites =3D element testsuites {=20 testsuite*=20 }
The JUnit XML report format originates the JUnit ANT task - this is the = definitive source for the JUnit Report XML format - and source code can be = found on the apache SVN repository here:
This can be useful if attempting to do anything "tricky" with JUni= t output where you need to confirm it's compliant.
Here are some additional topics on stack overflow that discuss the JUnit= XML format which can be useful for learning about the schema for the JUnit= XML results format, as well to get hints about what minimum subset is norm= ally suitable for most tools such as Jenkins (the same rules apply to ET ge= nerally as well).