1 unstable release

0.1.0 Sep 25, 2022

#674 in Testing

Download history 1/week @ 2024-02-17 11/week @ 2024-02-24 4/week @ 2024-03-02 6/week @ 2024-03-09 6/week @ 2024-03-16 2/week @ 2024-03-23 24/week @ 2024-03-30 21/week @ 2024-04-06 4/week @ 2024-04-13 4/week @ 2024-04-20

53 downloads per month
Used in 2 crates

MIT/Apache

28KB
776 lines

testdata-rs

Macros and helper functions for file-based testing.

Example

The crate's main feature is testdata::files, which automatically finds test files and expands to multiple tests.

use std::str;
use testdata::{assert_snapshot, TestFile};

#[testdata::files(rebuild = "tests/example.rs")]
#[test]
fn test_foo(
    #[glob = "tests/fixtures/**/*-in.txt"] input: &TestFile,
    #[glob = "tests/fixtures/**/*-out.txt"] output: &TestFile,
) {
    let s = input.raw_read();
    let s = str::from_utf8(&s).unwrap();
    let result = s.to_uppercase();
    assert_snapshot!(result, snapshot = output);
}

More documents will be added in the later versions.


lib.rs:

Runtime definitions for the testdata crate.

Dependencies

~1–10MB
~79K SLoC