11# Assert CLI
22
3- > Test CLI Applications.
3+ > ** Test CLI Applications** - This crate checks the output of a child process is as expected .
44
5- Currently, this crate only includes basic functionality to check the output of a child process
6- is as expected.
7-
8- [ ![ Build Status] ( https://travis-ci.org/killercup/assert_cli.svg )] ( https://travis-ci.org/killercup/assert_cli ) [ ![ Coverage Status] ( https://coveralls.io/repos/killercup/assert_cli/badge.svg?branch=master&service=github )] ( https://coveralls.io/github/killercup/assert_cli?branch=master )
9-
10- ** [ Documentation] ( http://killercup.github.io/assert_cli/ ) **
5+ [ ![ Build Status] ( https://travis-ci.org/killercup/assert_cli.svg )] ( https://travis-ci.org/killercup/assert_cli ) [ ![ Documentation] ( https://img.shields.io/badge/docs-master-blue.svg )] [ Documentation ]
116
127## Install
138
@@ -30,13 +25,13 @@ fn main() {
3025}
3126```
3227
33- Or if you'd rather use the macro:
28+ Or if you'd rather use the macro, to save you some writing :
3429
3530``` rust
3631#[macro_use] extern crate assert_cli;
3732
3833fn main () {
39- assert_cmd! (echo 42 ) . succeeds () . and ( ). prints (" 42" ). unwrap ();
34+ assert_cmd! (echo " 42 " ). prints (" 42" ). unwrap ();
4035}
4136```
4237
@@ -47,33 +42,42 @@ And here is one that will fail (which also shows `execute` which returns a
4742#[macro_use] extern crate assert_cli;
4843
4944fn main () {
50- let test = assert_cmd! (grep amet Cargo . toml)
51- . fails_with (1 )
45+ let test = assert_cmd! (ls " foo-bar-foo" )
46+ . fails ()
47+ . and ()
48+ . prints_error (" foo-bar-foo" )
5249 . execute ();
53- assert! (test . is_err ());
50+ assert! (test . is_ok ());
5451}
5552```
5653
57- If you want to check for the program's output, you can use ` print ` or
58- ` print_exactly ` :
54+ If you want to match the program's output _ exactly _ , you can use
55+ ` prints_exactly ` :
5956
60- ``` rust,should_panic="Assert CLI failure"
57+ ``` rust,should_panic
6158#[macro_use] extern crate assert_cli;
6259
6360fn main() {
64- assert_cmd!("wc" "README.md")
61+ assert_cmd!(wc "README.md")
6562 .prints_exactly("1337 README.md")
6663 .unwrap();
6764}
6865```
6966
70- this will show a nice, colorful diff in your terminal, like this:
67+ ... which has the benefit to show a nice, colorful diff in your terminal,
68+ like this:
7169
7270``` diff
7371- 1337
7472+ 92
7573```
7674
75+ ** Tip** : Enclose arguments in the ` assert_cmd! ` macro in quotes ` " ` ,
76+ if there are special characters, which the macro doesn't accept, e.g.
77+ ` assert_cmd!(cat "foo.txt") ` .
78+
79+ More detailed information is available in the [ documentation] . :-)
80+
7781## License
7882
7983Licensed under either of
@@ -89,3 +93,5 @@ Unless you explicitly state otherwise, any contribution intentionally
8993submitted for inclusion in the work by you, as defined in the Apache-2.0
9094license, shall be dual licensed as above, without any additional terms or
9195conditions.
96+
97+ [ Documentation ] : http://killercup.github.io/assert_cli/
0 commit comments