3 unstable releases
Uses new Rust 2024
new 0.2.4 | Apr 30, 2025 |
---|---|
0.2.3 | Apr 30, 2025 |
0.1.0 | Apr 30, 2025 |
#304 in Testing
77 downloads per month
13KB
fstest
fstest
provides a procedural macro attribute for simplifying integration tests involving
temporary file system setups and optional Git repository initialization.
This crate defines the #[fstest]
macro, which wraps a test function and handles:
- Creation of a temporary working directory
- Optional initialization of a Git repository in the temporary directory
- Copying of specified input files into the temp directory
- Restoring the original working directory after test execution
Usage
use fstest::cmd_test;
#[cmd_test(repo = true, files = ["tests/data/input.txt", "tests/data/config.toml"])] //arguments are optional!
fn my_test(tempdir: &std::path::Path) {
// test code working within `tempdir`
}
See examples folder for examples.
Installation
Add crate and tempfile to your dev dependencies.
[dev-dependencies]
fstest = "0.1.0"
tempfile = "3.19.1"
Dependencies
~11–22MB
~376K SLoC