Skip to main content

test_suite

Macro test_suite 

Source
macro_rules! test_suite {
    ($ty:ty, $storage:ident, $init:expr, $cases:expr, $hooks:expr, [$($name:ident),* $(,)?] $(,)?) => { ... };
    ($ty:ty, $storage:ident, $cases_static:ident, $init:expr, $hooks:expr, $s:ident =>
        $($name:ident => $body:block),* $(,)?
    ) => { ... };
}
Expand description

Emit one #[test] per listed case name. Each test locks a shared suite behind a std::sync::Mutex in a std::sync::OnceLock keyed by $storage, then calls run with RunConfig::filter and your HookFns.

$ty must be Send. The harness may run tests in any order or in parallel; if one case depends on another having run first on the same suite, see the macro docs on ordering, or call run once with RunConfig::all instead.

§Declaration

Split cases and names — pass a [cases!] slice (or any &[Case<S>]) plus a matching list of identifiers for the generated #[test] functions:

test_suite! {
    $ty:ty, $storage:ident, $init:expr, $cases:expr, $hooks:expr, [$($name:ident),* $(,)?] $(,)?
}

Inline cases — same syntax as [cases!], written once; the macro defines $cases_static and emits one #[test] fn $name per case:

test_suite! {
    $ty:ty, $storage:ident, $cases_static:ident, $init:expr, $hooks:expr, $s:ident =>
        $($name:ident => $body:block),* $(,)?
}