Expand description
§libtest-mimic-collect
Automatically collects tests marked using #[test] attribute. Tests can then be run using
libtest_mimic_collect::TestCollection::run().
§Installation
- Add
libtest-mimic-collectto the dev-dependencies.
§Example
Specify your test target in Cargo.toml:
[[test]]
name = "test"
harness = false
path = "lib/test.rs"You might also disable the default tests:
[lib]
test = falseCreate a test module lib/test.rs:
mod my_mod1;
mod my_mod2;
// ...
#[macro_use]
extern crate libtest_mimic_collect;
#[test]
fn test_success() {
()
}
#[test]
fn test_failure() -> Result<(), String> {
Err("Something went wrong".into())
}
#[test]
fn test_assert() {
assert_eq!(1, 2);
}
pub fn main() {
libtest_mimic_collect::TestCollection::run();
}§License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
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.
Re-exports§
pub use libtest_mimic;
Structs§
- Test
Collection - A global collection of tests. Tests can be added to the collection from different modules and then run.
Traits§
- Convert
Result - Converts typical test function results to the Result type used by libtest_mimic.
Attribute Macros§
- ctor
- This macro is used by #test to add tests to the test collection. Marks a function or static variable as a library/executable constructor. This uses OS-specific linker sections to call a specific function at load time.
- test
- This macro automatically adds tests marked with #test to the test collection. Tests then can be run with libtest_mimic_collect::TestCollection::run(). This macro automatically adds tests marked with #test to the test collection. Tests then can be run with libtest_mimic_collect::TestCollection::run().