#test #framework #libtest #built-in

libtest-mimic

Write your own test harness that looks and behaves like the built-in test harness used by rustc --test

3 releases (breaking)

0.3.0 Jun 28, 2020
0.2.0 Oct 2, 2019
0.1.0 Jul 23, 2018

#23 in Testing

Download history 641/week @ 2020-03-15 967/week @ 2020-03-22 609/week @ 2020-03-29 620/week @ 2020-04-05 550/week @ 2020-04-12 699/week @ 2020-04-19 496/week @ 2020-04-26 721/week @ 2020-05-03 593/week @ 2020-05-10 686/week @ 2020-05-17 780/week @ 2020-05-24 832/week @ 2020-05-31 1317/week @ 2020-06-07 2356/week @ 2020-06-14 2212/week @ 2020-06-21 2136/week @ 2020-06-28

4,111 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

38KB
675 lines

libtest-mimic

Build Status crates.io version docs

Write your own test harness that looks and behaves like the built-in test harness (used by rustc --test)!

This is a simple and small testing framework that mimics the original libtest (used by rustc --test). That means: all output looks pretty much like cargo test and most CLI arguments are understood and used. With that plumbing work out of the way, your test runner can concentrate on the actual testing.

See it in action (with the tidy example):

asciicast

Example

extern crate libtest_mimic;

use libtest_mimic::{Arguments, Test, Outcome, run_tests};


// Parse command line arguments
let args = Arguments::from_args();

// Create a list of tests (in this case: three dummy tests)
let tests = vec![
    Test::test("toph"),
    Test::test("sokka"),
    Test {
        name: "long_computation".into(),
        kind: "".into(),
        is_ignored: true,
        is_bench: false,
        data: (),
    },
];

// Run all tests and exit the application appropriatly (in this case, the
// test runner is a dummy runner which does nothing and says that all s
// passed).
run_tests(&args, tests, |test| Outcome::Passed).exit();

For more examples, see examples/.


License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~3.5MB
~64K SLoC