Expand description
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.
Modules§
- __rt
- pretty_
assertions - Pretty Assertions
Macros§
Structs§
- ArgSpec
- Configuration for a specific argument in a file-based test.
- Glob
Pattern - A parsed glob pattern, like
tests/fixtures/**/*.json
. - Glob
Spec - Configurations for finding test files in a file-based test.
- Test
File
Enums§
- Glob
Error - Represents the glob error.
- Glob
Parse Error - A syntax error in a glob pattern.
- Snapshot
Mode
Traits§
Functions§
- assert_
snapshot_ helper - pending
- touch
- An equivalent to the
touch
command.