JUnit XML
The JUnit XML format is a standardized output format for test results generated by test automation frameworks. It is widely used in continuous integration (CI) systems to record and visualize test results. Originally designed for the JUnit testing framework in Java, it is now supported by many testing tools across languages.
A test case is successful (passed) unless there is a different result element beneath it. Most tools recognize result elements such as skipped, failure, and error.
Â
JUnit XML file example:
<?xml version="1.0" encoding="UTF-8"?>
<testsuites id="" name="" tests="4" failures="2" skipped="1" errors="0" time="30.54786">
<testsuite name="example.spec.ts" timestamp="2024-11-25T12:12:42.765Z" hostname="chromium" tests="4" failures="2" skipped="1" time="36.873" errors="0">
<testcase name="Regression - Import test execution results by API 1 (no failure, no error=>passed)- Playwright" classname="example.spec.ts" time="0.95">
<properties>
<property name="issue-key" value="QAREG-430">
</property>
</properties>
</testcase>
<testcase name="Regression - Import test execution results by API 2 (failure) - Playwright" classname="example.spec.ts" time="5.899">
<properties>
<property name="issue-key" value="ABC-584">
</property>
</properties>
<failure message="example.spec.ts:9:5 Regression - Import test execution results by API 2 (failure) - Playwright" type="FAILURE">
Error: Timed out 5000ms waiting for expect(locator).toHaveTitle(expected)
</failure>
</testcase>
<testcase name="Regression - Import test execution results by API 4 (skipped=>default status)- Playwright" classname="example.spec.ts" time="0">
<properties>
<property name="issue-key" value="ABC-123">
</property>
</properties>
<skipped>
</skipped>
</testcase>
</testsuite>
</testsuites>
Â
Main elements and their description:
Element | Description |
---|---|
<testsuites> … <testsuites> | A collection of multiple test suites or test cases, typically representing a group of related tests. Often the root element of the JUnit XML. ATTRIBUTES
optional:
CHILDREN: |
<testsuite> … <testsuite> | A group of test cases that share a common setup or purpose, often corresponding to a specific module or functionality. ATTRIBUTES
optional:
CHILDREN: |
<testcase> … <testcase> | An individual unit of testing that verifies a specific functionality or behavior of the application. ATTRIBUTES
optional:
CHILDREN: |
<properties>… </properties> | An optional element that contains CHILDREN: |
<property>… </property> | Used to represent environment variables, configuration settings, or metadata. ATTRIBUTES
|
<failure>… </failure> | Indicates a test case that failed. ATTRIBUTES optional:
The stack trace or error message. |
<error>… </error> | Usually Indicates a test case has failed cause of an unexpected error like a null pointer. ATTRIBUTES optional:
The stack trace or error message. |
<skipped>… </skipped> | Indicates a test case that was skipped. ATTRIBUTES optional:
CONTENT optional: Details about why the test was skipped. |
<system-out>… </system-out>  <system-err>… </system-err> | Captures data written to standard out or standard error for the test suite/test case. CONTENT: Captured data. |
Â