fixtures
fixtures is a Rust crate which allows developers to run tests against fixture files. It provides a procedural macro
to generate tests from the filesystem, using glob patterns.
Example
To ensure tests re-run when the fixtures change, add the following line to build.rs.
watch_dir;
Comparison to datatest-stable
| fixtures | datatest-stable | |
|---|---|---|
Requires setting harness = false in Cargo.toml |
🏅 no | yes |
Supports non-test configurations e.g. criterion |
🏅 yes | no |
| Supports embedding directories at compile time | no | 🏅 yes |
Works with cargo-nextest |
🏅 yes | 🏅 yes |
| Supports arbitrary function signatures | 🏅 yes | no |
| Supports automatically injecting file contents | no | 🏅 yes |
Allows #[ignore]ing tests by glob patterns |
🚧 wip | no |
Usage
Installation
[]
= "1"
[]
= "1"
Setup
Add the following code to build.rs to watch your fixtures directories for changes.
Basic Usage
The above example expands to:
Multiple Globs
Extended Glob Syntax
fixtures supports gitignore's extended glob syntax.
Advanced Usage
Criterion
fixtures can be used with criterion as shown in the following example:
// Equivalent to criterion_group!(benches, bench::expansion_1, bench::expansion_2, ...);
criterion_main!;