Crate assert_cmd[−][src]
Assert [Command
][Command] - Easy command initialization and assertions.
assert_cmd
includes support for:
- Setting up your program-under-test (see
CommandCargoExt
,CommandStdInExt
). - Verifying your program-under-test (see
OutputOkExt
,OutputAssertExt
).
[dependencies]
assert_cmd = "0.9"
Example
Here's a trivial example:
ⓘThis example is not tested
extern crate assert_cmd; use std::process::Command; use assert_cmd::prelude::*; fn main() { let mut cmd = Command::main_binary().unwrap(); cmd.assert().success(); }
Relevant crates
Other crates that might be useful in testing command line programs.
- duct for orchestrating multiple processes.
- assert_fs for filesystem fixtures and assertions.
- dir-diff for testing file side-effects.
- tempfile for scratchpad directories.
Migrating from assert_cli
v0.6
assert_cmd
is the successor to the original assert_cli
:
- More flexible, reusable assertions (also used by assert_fs).
- Can integrate with other process-management crates, like
duct
. - Addresses several architectural problems.
Key points in migrating from assert_cli
:
Re-exports
pub use assert::Assert; |
pub use assert::OutputAssertExt; |
pub use cargo::CommandCargoExt; |
Modules
assert |
|
cargo |
Simplify running |
prelude |
Extension traits that are useful to have available. |
Structs
OutputError |
|
StdInCommand |
|
StdInCommandBuilder |
For adding a stdin to a |
Traits
CommandStdInExt |
Write to |
OutputOkExt |
Converts a type to an |
Type Definitions
OutputResult |