JUnit-Parser v1.0.0

Testing is a very important part of software engineering. Tests results are usually written as JUnit reports, sometimes also referred as xUnit since the file format is an XML document.

I wanted to store and analyze such documents. Working with hundreds of JUnit reports can be cumbersome and I wanted to write a dedicated tool to process a large set of JUnit reports.

As you know, I enjoy writing rust code but sadly there is no library to help parse JUnit documents. That’s why I wrote a small library to do just that. It is simply called JUnit-Parser.

It is based on quick-xml to parse efficiently the XML files.

It parses all the different JUnit files I encountered and I have added support for some optional attributes.

The API is very simple as can be seen in the example below:

Example

use std::io::Cursor;
let xml = r#"
<testsuite tests="3" failures="1">
  <testcase classname="foo1" name="ASuccessfulTest"/>
  <testcase classname="foo2" name="AnotherSuccessfulTest"/>
  <testcase classname="foo3" name="AFailingTest">
    <failure type="NotEnoughFoo"> details about failure </failure>
  </testcase>
</testsuite>
"#;
let cursor = Cursor::new(xml);
let r = junit_parser::from_reader(cursor);
assert!(r.is_ok());
let t = r.unwrap();
assert_eq!(t.suites.len(), 1);
let ts = &t.suites[0];
assert_eq!(ts.tests, 3);
assert_eq!(ts.failures, 1);
assert_eq!(ts.cases.len(), 3);
assert!(ts.cases[0].status.is_success());
assert!(ts.cases[2].status.is_failure());

Release & Usage

Junit-Parser is licensed under the BSD 2-Clause license.

After few iterations over the years, I think it is time to release v1.0.0.

The 1.0.0 release brings a better support for JUnit files along with updated dependencies. I have also taken into account some commits from forks on github, like the optional serde feature to help serialize / deserialize the public types used to represent a JUnit file.

You can find more about it on the following links:

Future

I’ve added Dependabot and a small CI to help me keep it up-to-date.