per_test_directory

Crates.ioper_test_directory
lib.rsper_test_directory
version0.1.0
sourcesrc
created_at2019-09-10 11:55:41.964559
updated_at2019-09-10 11:55:41.964559
descriptionfixture/attribute macro to create one directory per test run.
homepage
repositoryhttps://github.com/TyberiusPrime/per_test_directory
max_upload_size
id163809
size3,974
Florian Finkernagel (TyberiusPrime)

documentation

README

per_test_directory

This crate introduces an attribute macro #[per_test_directory] that will create a directory test_runs/module_name.test_function_name and change the current working directory to it while running.

If the test is successful, the directory is removed. Otherwise, it is being kept for your inspection. Either way, the current directory is reset after the test run.

Example:

#[cfg(test)]
mod tests {
    use std::fs::File;
    use std::io::prelude;

    #[test]
    #[per_test_directory_macros]
    fn test_example() {
        let mut f = File::create("foo.txt")?;
        //actually in test_runs/tests.test_example/foo.txt
        file.write_all(b"hello");
        panic!("let's keep the file!");
    } }
Commit count: 1

cargo fmt