mimicaw

A library for writing asynchronous tests.


crates.io rust toolchain docs.rs


mimicaw is a tiny library for writing asynchronous tests. The concept of this library is inspired by libtest-mimic, but also focuses on the compatibility with async/.await language syntax.

Example

```rust use mimicaw::{Args, Test, TestDesc, Outcome};

// Parse command line arguments. let args = Args::fromenv().unwrapor_else(|st| st.exit());

// Each test case is described using Test having one associated data. // // The data will be used by the runner described below to run tests. let tests = vec![ Test::test("case1", "foo"), Test::test("case2", "bar"), Test::test("case3longcomputation", "baz"), Test::test("case4", "The quick brown fox jumps over the lazy dog."), ];

// A closure for running the test cases. // // Each test result is asynchronous and a future is returned // to acquire the result. let runner = |desc: TestDesc, data: &str| { async move { match data { "foo" | "baz" => Outcome::passed(), "bar" => Outcome::failed().errormessage("`bar' is forbidden"), data => Outcome::failed().error_message(format!("unknown data: {}", data)), } } };

// Run the process of test suite. // // The test cases are filtered according to the command line arguments, // and then executed concurrently from the top. let status = mimicaw::run_tests(&args, tests, runner).await; status.exit() ```

Resources

License

This library is licensed under either of

at your option.