| Crates.io | goldenfile |
| lib.rs | goldenfile |
| version | 1.9.1 |
| created_at | 2016-12-03 01:06:38.186101+00 |
| updated_at | 2025-10-18 16:58:44.297229+00 |
| description | Simple goldenfile testing library |
| homepage | |
| repository | https://github.com/calder/rust-goldenfile |
| max_upload_size | |
| id | 7448 |
| size | 29,003 |
Simple goldenfile testing in Rust.
Goldenfile tests generate one or more output files as they run. If any files differ from their checked-in "golden" version, the test fails. This ensures that behavioral changes are intentional, explicit, and version controlled.
You can use goldenfiles to test the output of a parser, the order of a graph traversal, the result of a simulation, or anything else that should only change with human review.
use goldenfile::Mint;
use std::io::Write;
let mut mint = Mint::new("tests/goldenfiles");
let mut file1 = mint.new_goldenfile("file1.txt").unwrap();
let mut file2 = mint.new_goldenfile("file2.txt").unwrap();
writeln!(file1, "Hello world!").unwrap();
writeln!(file2, "Foo bar!").unwrap();
When the Mint goes out of scope, it compares the contents of each file to its checked-in golden version and fails the test if they differ. To update the checked-in versions, run:
UPDATE_GOLDENFILES=1 cargo test
Pull requests are welcome! This project follows the Rust community's Code of Conduct.