Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/calder/rust-goldenfile
Simple goldenfile testing in Rust.
https://github.com/calder/rust-goldenfile
Last synced: about 1 month ago
JSON representation
Simple goldenfile testing in Rust.
- Host: GitHub
- URL: https://github.com/calder/rust-goldenfile
- Owner: calder
- License: mit
- Created: 2016-12-01T19:14:43.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-04-16T15:27:11.000Z (about 2 months ago)
- Last Synced: 2024-04-16T17:08:09.099Z (about 2 months ago)
- Language: Rust
- Homepage:
- Size: 67.4 KB
- Stars: 35
- Watchers: 2
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-rust - goldenfile
- awesome-rust - goldenfile - A library providing a simple API for goldenfile testing. [![build badge](https://api.travis-ci.org/calder/rust-goldenfile.svg?branch=master)](https://travis-ci.org/calder/rust-goldenfile) (Development tools / Testing)
- awesome-stars - calder/rust-goldenfile - Simple goldenfile testing in Rust. (Rust)
- awesome-rust-cn - goldenfile - (开发工具 Development tools / 测试 Testing)
- awesome-rust - goldenfile - A library providing a simple API for goldenfile testing. [![build badge](https://api.travis-ci.org/calder/rust-goldenfile.svg?branch=master)](https://travis-ci.org/calder/rust-goldenfile) (Development tools / Testing)
README
# 👑 Rust Goldenfile
[![Documentation](https://docs.rs/goldenfile/badge.svg)](https://docs.rs/goldenfile) [![Latest Version](https://img.shields.io/crates/v/goldenfile.svg)](https://crates.io/crates/goldenfile) [![Build Status](https://github.com/calder/rust-goldenfile/actions/workflows/test.yaml/badge.svg)](https://github.com/calder/rust-goldenfile/actions/workflows/test.yaml?query=branch%3Amain) [![Coverage Status](https://codecov.io/github/calder/rust-goldenfile/branch/main/graph/badge.svg?token=ROF7q6w5no)](https://app.codecov.io/gh/calder/rust-goldenfile)
**Simple goldenfile testing in Rust.**
[Goldenfile](https://softwareengineering.stackexchange.com/questions/358786/what-is-golden-files) 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
```rust
extern crate goldenfile;use std::io::Write;
use goldenfile::Mint;
#[test]
fn test() {
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();write!(file1, "Hello world!").unwrap();
write!(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:
```sh
UPDATE_GOLDENFILES=1 cargo test
```## Contributing
Pull requests are welcome! This project follows the Rust community's [Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct).