Crate after_test

source ·
Expand description

The [cleanup] macro iterates over all functions marked as tests in the input token stream and adds a call to the provided function passed as an attribute to the macro.

This macro can be added to the top of your test module and will ensure that the passed cleanup function is called at each test function’s end.

§Example

use after_test::cleanup;

#[cleanup(my_clean_up)]
#[cfg(test)]
mod tests {
    fn my_clean_up() {
       println!("cleaning up resources");
    }   

    #[test]
    fn a_test() {}
}

Attribute Macros§