Expand description
In-process test harness for apps built on the standout CLI framework.
TestHarness bundles the scattered injection seams — environment
detectors, env vars, working directory, stdin, clipboard, output mode,
and tempdir fixtures — into a single fluent builder, and restores every
override when the harness is dropped.
§Example
use standout_test::TestHarness;
let result = TestHarness::new()
.env("HOME", "/tmp/fake")
.clipboard("pasted content")
.terminal_width(80)
.piped_stdin("extra input\n")
.no_color()
.fixture("notes/todo.txt", "- buy milk\n")
.run(app, cmd, ["myapp", "notes", "list"]);
result.assert_success();
result.assert_stdout_contains("buy milk");§Concurrency and restoration
The harness mutates process-global state (env vars, cwd, environment
detectors, default input readers). Tests that instantiate a
TestHarness must be annotated #[serial] (from the re-exported
serial_test crate).
A Drop impl restores every override on both normal exit and panic
unwind, with two nuances:
- Env vars and cwd are restored to the values captured at
run()time. - Terminal detectors and default input readers are reset to the
library defaults, not to whatever was installed before
run(). This matches the behavior ofstandout_render::DetectorGuard. Don’t mix aTestHarnesswith a manually installed detector override on the same thread.
Structs§
- Test
Harness - Fluent builder for in-process CLI tests.
- Test
Result - Outcome of a
TestHarness::runinvocation.
Attribute Macros§
- serial
- Allows for the creation of serialised Rust tests