Expand description
Testing utilities for click-rs applications.
This module provides utilities for testing CLI applications built with click-rs.
The main component is CliRunner, which allows invoking commands with captured
output for assertions.
§Reference
Based on Python Click’s testing.py.
§Example
use click::testing::CliRunner;
use click::command::Command;
let cmd = Command::new("hello")
.callback(|_ctx| {
// Your command logic here
Ok(())
})
.build();
let runner = CliRunner::new();
let result = runner.invoke(&cmd, &[]);
assert_eq!(result.exit_code, 0);
assert!(result.is_success());Structs§
- CliRunner
- A test runner for CLI applications.
- Echoing
Stdin - A wrapper that echoes input to output as it’s read.
- Invoke
Result - The result of invoking a command through
CliRunner. - Isolated
Filesystem - A temporary filesystem context for isolated testing.
Functions§
- make_
test_ context - Create a mock context for testing.