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.
Join the DZone community and get the full member experience.Join For Free
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
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.
Opinions expressed by DZone contributors are their own.