| 1 | # assert_cmd |
| 2 | |
| 3 | > **Assert `process::Command`** - Easy command initialization and assertions. |
| 4 | |
| 5 | [][Documentation] |
| 6 |  |
| 7 | [][Crates.io] |
| 8 | |
| 9 | `assert_cmd` aims to simplify the process for doing integration testing of CLIs, including: |
| 10 | - Finding your crate's binary to test |
| 11 | - Assert on the result of your program's run. |
| 12 | |
| 13 | ## Example |
| 14 | |
| 15 | Here's a trivial example: |
| 16 | |
| 17 | ```rust,no_run |
| 18 | use assert_cmd::Command; |
| 19 | |
| 20 | let mut cmd = Command::cargo_bin("bin_fixture").unwrap(); |
| 21 | cmd.assert().success(); |
| 22 | ``` |
| 23 | |
| 24 | See the [docs](http://docs.rs/assert_cmd) for more. |
| 25 | |
| 26 | ## Relevant crates |
| 27 | |
| 28 | Other crates that might be useful in testing command line programs. |
| 29 | * [escargot][escargot] for more control over configuring the crate's binary. |
| 30 | * [duct][duct] for orchestrating multiple processes. |
| 31 | * or [commandspec] for easier writing of commands |
| 32 | * [rexpect][rexpect] for testing interactive programs. |
| 33 | * [`assert_fs`][assert_fs] for filesystem fixtures and assertions. |
| 34 | * or [tempfile][tempfile] for scratchpad directories. |
| 35 | * [dir-diff][dir-diff] for testing file side-effects. |
| 36 | * [cross][cross] for cross-platform testing. |
| 37 | |
| 38 | [escargot]: http://docs.rs/escargot |
| 39 | [rexpect]: https://crates.io/crates/rexpect |
| 40 | [dir-diff]: https://crates.io/crates/dir-diff |
| 41 | [tempfile]: https://crates.io/crates/tempfile |
| 42 | [duct]: https://crates.io/crates/duct |
| 43 | [assert_fs]: https://crates.io/crates/assert_fs |
| 44 | [commandspec]: https://crates.io/crates/commandspec |
| 45 | [cross]: https://github.com/cross-rs/cross |
| 46 | |
| 47 | ## License |
| 48 | |
| 49 | Licensed under either of |
| 50 | |
| 51 | * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or <https://www.apache.org/licenses/LICENSE-2.0>) |
| 52 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or <https://opensource.org/license/mit>) |
| 53 | |
| 54 | at your option. |
| 55 | |
| 56 | ## Testimonials |
| 57 | |
| 58 | fitzgen |
| 59 | > assert_cmd is just such a pleasure to use every single time, I fall in love all over again |
| 60 | > |
| 61 | > bravo bravo WG-cli |
| 62 | |
| 63 | passcod |
| 64 | > Running commands and dealing with output can be complex in many many ways, so assert_cmd smoothing that is excellent, very much welcome, and improves ergonomics significantly. |
| 65 | |
| 66 | volks73 |
| 67 | > I have used [assert_cmd] in other projects and I am extremely pleased with it |
| 68 | |
| 69 | coreyja |
| 70 | > [assert_cmd] pretty much IS my testing strategy so far, though my app under test is pretty small. |
| 71 | > |
| 72 | > This library has made it really easy to add some test coverage to my project, even when I am just learning how to write Rust! |
| 73 | |
| 74 | ## Contribution |
| 75 | |
| 76 | Unless you explicitly state otherwise, any contribution intentionally |
| 77 | submitted for inclusion in the work by you, as defined in the Apache-2.0 |
| 78 | license, shall be dual-licensed as above, without any additional terms or |
| 79 | conditions. |
| 80 | |
| 81 | [Crates.io]: https://crates.io/crates/assert_cmd |
| 82 | [Documentation]: https://docs.rs/assert_cmd |