Crates.io | per_test_directory |
lib.rs | per_test_directory |
version | 0.1.0 |
source | src |
created_at | 2019-09-10 11:55:41.964559 |
updated_at | 2019-09-10 11:55:41.964559 |
description | fixture/attribute macro to create one directory per test run. |
homepage | |
repository | https://github.com/TyberiusPrime/per_test_directory |
max_upload_size | |
id | 163809 |
size | 3,974 |
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!");
} }