Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

assert-rs/assert_cli

Repository files navigation

Assert CLI

Test CLI Applications.

Currently, this crate only includes basic functionality to check the output of a child process is as expected.

Build Status Coverage Status

Documentation

Install

Just add it to your Cargo.toml:

[dependencies]
assert_cli = "0.1.0"

Example

Here's a trivial example:

extern crate assert_cli;
assert_cli::assert_cli_output("echo", &["42"], "42").unwrap();

Or if you'd rather use the macro:

#[macro_use] extern crate assert_cli;
assert_cli!("echo", &["42"] => Success, "42").unwrap();
assert_cli!("black-box", &["--special"] => Error 42, "error no 42\n").unwrap()

And here is one that will fail:

extern crate assert_cli;
assert_cli::assert_cli_output("echo", &["42"], "1337").unwrap();

this will show a nice, colorful diff in your terminal, like this:

-1337
+42

If you'd prefer to not check the output:

#[macro_use] extern crate assert_cli;
assert_cli::assert_cli("echo", &["42"]).unwrap();
assert_cli!("echo", &["42"] => Success).unwrap();

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.