quick-junit

quick-junit on crates.io Documentation (latest release) Documentation (main) Changelog License License

quick-junit is a JUnit/XUnit XML data model and serializer for Rust. This crate allows users to create a JUnit report as an XML file. JUnit XML files are widely supported by test tooling.

This crate is built to serve the needs of cargo-nextest.

Overview

The root element of a JUnit report is a Report. A Report consists of one or more TestSuite instances. A TestSuite instance consists of one or more TestCases.

The status (success, failure, error, or skipped) of a TestCase is represented by TestCaseStatus.

Features

This crate does not currently support deserializing JUnit XML. (PRs are welcome!)

Examples

```rust use quick_junit::*;

let mut report = Report::new("my-test-run"); let mut testsuite = TestSuite::new("my-test-suite"); let successcase = TestCase::new("success-case", TestCaseStatus::success()); let failurecase = TestCase::new("failure-case", TestCaseStatus::nonsuccess(NonSuccessKind::Failure)); testsuite.addtestcases([successcase, failurecase]); report.addtestsuite(testsuite);

const EXPECTED_XML: &str = r#" "#;

asserteq!(report.tostring().unwrap(), EXPECTED_XML); ```

For a more comprehensive example, including reruns and flaky tests, see fixture_tests.rs.

Minimum supported Rust version (MSRV)

The minimum supported Rust version is Rust 1.56.

While this crate is a pre-release (0.x.x) it may have its MSRV bumped in a patch release. Once a crate has reached 1.x, any MSRV bump will be accompanied with a new minor version.

Alternatives

Contributing

See the CONTRIBUTING file for how to help out.

License

This project is available under the terms of either the Apache 2.0 license or the MIT license.