28 releases (stable)

1.8.0 Feb 6, 2025
1.7.3 Sep 8, 2024
1.7.1 Apr 16, 2024
1.6.0 Nov 7, 2023
0.5.0 Dec 4, 2016

#31 in Testing

Download history 10209/week @ 2024-10-29 8840/week @ 2024-11-05 10868/week @ 2024-11-12 10682/week @ 2024-11-19 7530/week @ 2024-11-26 9312/week @ 2024-12-03 8521/week @ 2024-12-10 6670/week @ 2024-12-17 2847/week @ 2024-12-24 4528/week @ 2024-12-31 11653/week @ 2025-01-07 12454/week @ 2025-01-14 9954/week @ 2025-01-21 10061/week @ 2025-01-28 12026/week @ 2025-02-04 9768/week @ 2025-02-11

43,075 downloads per month
Used in 47 crates (24 directly)

MIT license

13KB
191 lines

👑 Rust Goldenfile

Documentation Latest Version Build Status Coverage Status

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.

Usage

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

Contributing

Pull requests are welcome! This project follows the Rust community's Code of Conduct.

Dependencies

~2–11MB
~132K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy