Skip to main content

teardown

Macro teardown 

Source
macro_rules! teardown {
    ($b:block) => { ... };
}
Expand description

Teardown for unit tests. The code of the teardown macro will be running automatically while the test will end, with test failure or not.

§Argument

  • $b - Code block for unit test teardown

§Example

 use std::fs;
 use std::fs::File;
 use std::path::Path;
 use utmt::teardown;

teardown!({fs::remove_file(Path::new("aFile.txt")).unwrap();});

§Note

While teardown!({...}) is using is advised to use setup!({...}) before, like this example:

 use std::fs;
 use std::fs::File;
 use std::path::Path;
 use utmt::{setup, teardown};

setup!({File::create(Path::new("aFile.txt")).unwrap();});
teardown!({fs::remove_file(Path::new("aFile.txt")).unwrap();});

// ... test code