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:
use 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 = new;
let r = from_reader;
assert!;
let t = r.unwrap;
assert_eq!;
let ts = &t.suites;
assert_eq!;
assert_eq!;
assert_eq!;
assert!;
assert!;
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:
I’ve added Dependabot and a small CI to help me keep it up-to-date.