Test CLI Applications.
Currently, this crate only includes basic functionality to check the output of a child process is as expected.
Just add it to your Cargo.toml
:
[dependencies]
assert_cli = "0.1.0"
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();
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
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.