Skip to content

TyberiusPrime/per_test_directory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

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!");
    } }

About

rust crate to have one directory per unit test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages