13 releases (stable)

1.3.1 Oct 28, 2024
1.2.4 Jul 19, 2024
1.1.0 Jan 10, 2024
1.0.0 Sep 24, 2023
0.1.0 Nov 8, 2020

#1336 in Parser implementations

Download history 220/week @ 2024-07-30 264/week @ 2024-08-06 557/week @ 2024-08-13 129/week @ 2024-08-20 84/week @ 2024-08-27 241/week @ 2024-09-03 208/week @ 2024-09-10 145/week @ 2024-09-17 285/week @ 2024-09-24 624/week @ 2024-10-01 411/week @ 2024-10-08 171/week @ 2024-10-15 256/week @ 2024-10-22 228/week @ 2024-10-29 128/week @ 2024-11-05 83/week @ 2024-11-12

714 downloads per month
Used in 2 crates

BSD-2-Clause

41KB
741 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.4–2.1MB
~39K SLoC