Skip to main content

command

Macro command 

Source
macro_rules! command {
    ($bin:literal $(,)?) => { ... };
    ($bin:literal, $($arg:expr),+ $(,)?) => { ... };
}
Expand description

Run a binary target from an integration test and capture stdout, stderr, and its exit status.

The first argument is the binary target’s Cargo name. Remaining arguments are passed to the process:

ⓘ
let output = usage::test::command!("greet", "hello", "Jeff").assert_success();
assert_eq!(output.stdout_text(), "hello, Jeff\n");

Put the test under tests/, where Cargo provides CARGO_BIN_EXE_<name> for each binary target in the package.