6 releases (3 stable)

new 1.1.1 May 14, 2024
1.1.0 Jan 10, 2024
1.0.0 Sep 24, 2023
0.2.0 Mar 20, 2021
0.1.0 Nov 8, 2020

#1736 in Parser implementations

Download history 84/week @ 2024-01-22 23/week @ 2024-01-29 190/week @ 2024-02-05 62/week @ 2024-02-12 77/week @ 2024-02-19 125/week @ 2024-02-26 196/week @ 2024-03-04 144/week @ 2024-03-11 75/week @ 2024-03-18 49/week @ 2024-03-25 117/week @ 2024-04-01 95/week @ 2024-04-08 140/week @ 2024-04-15 120/week @ 2024-04-22 104/week @ 2024-04-29 75/week @ 2024-05-06

454 downloads per month
Used in 2 crates

BSD-2-Clause

40KB
724 lines

CI Crates.io Docs License MSRV

JUnit-Parser

Rust library to parse JUnit XML files

Documentation

Example

Create a TestSuites structure from a JUnit XML data read from reader:

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());

Features

  • serde — Enables derive(serde::{Serialize,Deserialize}) on the Test* structures.
  • properties_as_hashmap (enabled by default) — Parse the properties element as a hashmap
  • properties_as_vector (enabled by default) — Parse the properties element as a vector

License

This project is available under the terms of either the BSD-2-Clause license.

Dependencies

~1.5–2.3MB
~43K SLoC