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.
- ✅ Serializing JUnit/XUnit to the Jenkins format.
- ✅ Including test reruns using
- ✅ Including flaky tests
- ✅ Including standard output and error
- ✅ Filtering out invalid XML characters (eg ANSI escape codes) from the output
- ✅ Automatically keeping track of success, failure and error counts
- ✅ Arbitrary properties and extra attributes
This crate does not currently support deserializing JUnit XML. (PRs are welcome!)
use quick_junit::*; let mut report = Report::new("my-test-run"); let mut test_suite = TestSuite::new("my-test-suite"); let success_case = TestCase::new("success-case", TestCaseStatus::success()); let failure_case = TestCase::new("failure-case", TestCaseStatus::non_success(NonSuccessKind::Failure)); test_suite.add_test_cases([success_case, failure_case]); report.add_test_suite(test_suite); const EXPECTED_XML: &str = r#"<?xml version="1.0" encoding="UTF-8"?> <testsuites name="my-test-run" tests="2" failures="1" errors="0"> <testsuite name="my-test-suite" tests="2" disabled="0" errors="0" failures="1"> <testcase name="success-case"> </testcase> <testcase name="failure-case"> <failure/> </testcase> </testsuite> </testsuites> "#; assert_eq!(report.to_string().unwrap(), EXPECTED_XML);
For a more comprehensive example, including reruns and flaky tests, see
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.
- junit-report: Older, more mature project. Doesn’t appear to support flaky tests or arbitrary properties as of version 0.7.0.
Represents text that is written out to standard output or standard error during text execution.
Custom properties set during test execution, e.g. environment variables.
The root element of a JUnit report.
Represents a single test case.
A rerun of a test.
Represents a single TestSuite.