Back to all articles

What is JUnit XML?

By Josh MarinacciApril 28, 2024

What is JUnit XML?

JUnit XML is an output format used by software testing frameworks. While most frameworks also produce plain text output meant for a human reader, the XML output allows other tools to process this data for report generation, running Continuous Integration (CI) systems, and diagnosing larger problems.

What does JUnit XML look like?

The format has an XML element for each test which produced it, called a testcase. These test cases are grouped into testsuite elements, which are then grouped together into a single testsuites element.

The output format closely matches the tests which produce it.  For example, this Javascript code tested with Jest:

1describe("Day of the Week Tests", () => {
2  test("today is Mon || Tues || Wed", () => {
3    const today = moment().format("dddd");
4    expect(["Monday", "Tuesday", "Wednesday"]).toContain(today);
5  });
7  test("today is Thursday or Friday", () => {
8    const today = moment().format("dddd");
9    expect(["Thursday", "Friday"]).toContain(today);
10  });
12  test("today is Saturday or Sunday", () => {
13    const today = moment().format("dddd");
14    expect(["Saturday", "Sunday"]).toContain(today);
15  });

will produce output that looks like this:

1<?xml version="1.0" encoding="UTF-8"?>
3<testsuites name="jest tests" tests="3" failures="2" errors="0" time="0.288">
4    <testsuite name="Day of the Week Tests" errors="0" failures="2" skipped="0" timestamp="2024-04-24T18:01:22" time="0.224" tests="3">
5        <testcase classname="Day of the Week Tests today is Mon || Tues || Wed" name="Day of the Week Tests today is Mon || Tues || Wed" time="0.004">
6    </testcase>
7    <testcase classname="Day of the Week Tests today is Thursday or Friday" name="Day of the Week Tests today is Thursday or Friday" time="0.003">
8      <failure>Error: expect(received).toContain(expected) // indexOf
9Expected value: &quot;Wednesday&quot;
10Received array: [&quot;Thursday&quot;, &quot;Friday&quot;]
11    at Object.toContain (/Users/josh/WebstormProjects/flake-factory/javascript/tests/jest/__tests__/jest.js:11:36)

Notice that the name attributes match the description arguments to the describe and test functions in the test code. Depending on the exact configuration, the XML output can also include the error count, time taken to run the tests, the package where the error occurred, the actual error outputs, and the filename of the file containing the test.

What is JUnit?

JUnit is a popular testing framework for Java. One of its notable features is its easy to use XML output.  JUnit was one of the earliest popular unit testing frameworks and over the years the output format has been adopted by many other users outside of the Java ecosystem, becoming a defacto standard for test output, now known as JUnit XML. While there is no official standard, JUnit XML it is widely used and broadly interoperable. This page is a good guide to the details of the “standard” as it exists in the real world. 

Enabling XML Output

Most testing frameworks can produce JUnit XML, but the process of enabling it varies from framework to framework.

Many test frameworks allow you to add additional fields and elements to the output that can be used for additional information only understood by certain tools and frameworks. Most tools will ignore extra elements they don’t understand. This can be helpful when customizing a development pipeline.


JUnit XML is a common format for test output produced and consumed by most testing tools and frameworks. It enables tool interoperability and integration.

Try it yourself or
request a demo

Get started for free

Try it yourself or
Request a Demo

Free for first 5 users