#junit #report #xml #xml-format #xunit

junit-report

创建与 JUnit 兼容的 XML 报告

17 个版本

0.8.3 2023 年 10 月 23 日
0.8.2 2022 年 12 月 16 日
0.8.1 2022 年 9 月 10 日
0.7.1 2022 年 4 月 27 日
0.1.2 2018 年 11 月 22 日

49测试

Download history 24815/week @ 2024-04-27 26186/week @ 2024-05-04 25332/week @ 2024-05-11 43425/week @ 2024-05-18 37492/week @ 2024-05-25 42050/week @ 2024-06-01 42935/week @ 2024-06-08 39325/week @ 2024-06-15 41626/week @ 2024-06-22 29596/week @ 2024-06-29 21807/week @ 2024-07-06 18281/week @ 2024-07-13 21465/week @ 2024-07-20 21419/week @ 2024-07-27 22219/week @ 2024-08-03 18397/week @ 2024-08-10

86,687 每月下载量
15 Crates 中使用 (11 个直接使用)

MIT 许可证

38KB
746

Rust 中的 JUnit 报告

在 Rust 中生成与 JUnit 兼容的 XML 报告。

示例


    use junit_report::{datetime, Duration, ReportBuilder, TestCase, TestCaseBuilder, TestSuite, TestSuiteBuilder};
    use std::fs::File;

    // Create a successful test case
    let test_success = TestCaseBuilder::success("good test", Duration::seconds(15))
        .set_classname("MyClass")
        .set_filepath("MyFilePath")
        .build();

    // Create a test case that encountered an unexpected error condition
    let test_error = TestCase::error(
        "error test",
        Duration::seconds(5),
        "git error",
        "unable to fetch",
    );

    // Create a test case that failed because of a test failure
    let test_failure = TestCase::failure(
        "failure test",
        Duration::seconds(10),
        "assert_eq",
        "not equal",
    );

    // Next we create a test suite named "ts1" with not test cases associated
    let ts1 = TestSuite::new("ts1");

    // Then we create a second test suite called "ts2" and set an explicit time stamp
    // then we add all the test cases from above
    let timestamp = datetime!(1970-01-01 00:01:01 UTC);
    let ts2 = TestSuiteBuilder::new("ts2")
        .set_timestamp(timestamp)
        .add_testcase(test_success)
        .add_testcase(test_error)
        .add_testcase(test_failure)
        .build();

    // Last we create a report and add all test suites to it
    let r = ReportBuilder::new()
        .add_testsuite(ts1)
        .add_testsuite(ts2)
        .build();

    // The report can than be written in XML format to any writer
    let mut file = File::create("my-junit.xml").unwrap();
    r.write_xml(&mut file).unwrap();

依赖项

~3.5MB
~73K SLoC