Skip to main content

Module fixture

Module fixture 

Source
Available on crate feature fixture only.
Expand description

Files for integration tests, written through one call instead of fs::create_dir_all, fs::write, and an expect per file.

A Suite owns a temporary directory named after the test file, and each Suite::scenario owns its own directory inside it. Both are removed when the value drops, so a test cleans up by going out of scope. A write that fails panics with the path it could not write. A broken fixture is a broken test, and the message names the file.

use ctl_core::fixture::Suite;

let suite = Suite::new("example");
let root = suite.scenario("one");
let path = root.file("notes/a.md", "hello");
assert!(path.starts_with(root.path()));
assert_eq!(root.read("notes/a.md"), "hello");

Structsยง

Root
A temporary directory a test writes files into, alive no longer than the suite it sits in.
Suite
A temporary directory for one test file.