Macro oysterpack_testing::op_tests_mod
source · macro_rules! op_tests_mod {
( $($target:expr => $level:ident),* ) => { ... };
}
Expand description
Generates a module named tests
, which provides test support functionality.
run_test
function ensures logging is configured for the log crate- the root log level will be set to Warn
- the crate’s log level will be set to Debug
run_test
function will log the test execution timerun_test
will be bound to the crate’s root path, i.e., it can be invoked as::run_test("test_name",|| { ... })
, but annotated with#[cfg(test)]
. Thus, it will only be available when running tests.
Example
#[cfg(test)]
#[macro_use]
extern crate oysterpack_testing;
#[cfg(test)]
op_tests_mod!();
#[test]
fn foo_test() {
::run_test("foo_test", || info!("SUCCESS"));
}
Example - configuring target log levels
#[cfg(test)]
#[macro_use]
extern crate oysterpack_testing;
#[cfg(test)]
op_tests_mod! {
"foo" => Info,
"bar" => Error
}
#[test]
fn foo_test() {
::run_test("foo_test", || info!(target: "foo", "SUCCESS"));
}
- in the above example, the
foo
target log level is set toInfo
and thebar
target log level is set to Error