This crate is meant to be used as a dev dependency. Its purpose is to provides the testing support to help reduce boilerplate, duplication, and provides standardization.
The following macros are provided:
- optestsmod
- provides support to configure logging for tests
- logs test execution time
- optest
- used to generate test functions that leverage the tests
module generated by optests_mod!()
```rust
extern crate oysterpack_testing;
optestsmod!();
mod footest { // the macro creates a test function named 'foo' optest!(foo, { info!("SUCCESS"); });
#[test] fn footest() { // alternatively use ::runtest("test name",|| { // test code }) ::runtest("footest", || { // by default the crate's log level is set to Debug debug!("SUCCESS") }); } } ```
```rust
extern crate oysterpack_testing;
optestsmod! { "foo" => Info, "bar" => Error }
mod footest { optest!(foo, { info!("this will be logged because this crate's log level is Debug"); info!(target: "foo", "foo info will be logged"); info!(target: "bar", "* bar info will not be logged *"); error!(target: "bar", "bar error will be logged"); });
#[test] fn footest() { ::runtest("foo_test", || { debug!("SUCCESS") }); } }
```