Over a million developers have joined DZone.

Viewing JUnit XML Files Locally

DZone's Guide to

Viewing JUnit XML Files Locally

In this tutorial, you'll learn how to view the contents of a JUnit XML file locally and read its contents in the form of a table.

· DevOps Zone ·
Free Resource

The need for DevOps innovation has never been greater. Get the results from over 100 business value assessments in this whitepaper, Digital Darwinism: Driving Digital Transformation, to see the positive impact of DevOps first hand.

In order to allow Iridium to be integrated into CI systems, one of the report files that is generated is a JUnit XML file. Almost every CI has a plugin that can parse a JUnit XML file, but sometimes it is nice to be able to view the contents of this file locally.

The trouble is that this file is not that easy to read in its raw form. You can find what you need if you dig into the format, but I’d still rather have this information presented in a nice table.

Fortunately, there are some open source tools you can use to quickly browse the contents of a JUnit XML file.

First, you will need a JUnit XML file to view. Install Java 8, download the WebStart file from this link and run the file to execute a simple test. The results of the test will be saved to ~/WebAppTestingReports/<yyMMdd>/MergedResults.xml. You should see a file like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<testsuite failures="0" skipped="0" tests="1" time="56.422665">
    <testcase classname="Google Test" name="1: Launch Google" time="56.422665">
        <system-out>Given I open the page "https://google.com"..................................passed
When the element found by "Google Search" is present........................passed
Then the browser title should be "Google"...................................passed

Then you will need to install junit-viewer, which is built on top of NodeJS. This app will convert the JUnit XML file into HTML.

sudo npm install junit-viewer -g

Next, you need to install bcat, which is a Ruby Gem that can be used to pipe HTML directly to the browser.

sudo gem install bcat

Finally, these two tools can then be combined to display the JUnit XML file directly in the browser. 

junit-viewer --results=MergedReport.xml | bcat

Image title

If you are interested in writing end-to-end tests like the one shown above, check out the Iridium documentation, and take a look at the course on Udemy. Iridium itself is a free and open source project on GitHub.

Interested in Kubernetes but unsure where to start? Check out this whitepaper, A Roundup of Managed Kubernetes Platforms from Codeship by Cloudbees, for an overview and comparison of Kubernetes platforms. 

junit ,iridium ,devops ,software testing

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}