1# assert_cmd 2 3> **Assert `process::Command`** - Easy command initialization and assertions. 4 5[![Build Status](https://dev.azure.com/assert-rs/assert-rs/_apis/build/status/assert_cmd?branchName=master)](https://dev.azure.com/assert-rs/assert-rs/_build/latest?definitionId=3&branchName=master) 6[![Documentation](https://img.shields.io/badge/docs-master-blue.svg)][Documentation] 7![License](https://img.shields.io/crates/l/assert_cmd.svg) 8[![Crates Status](https://img.shields.io/crates/v/assert_cmd.svg)](https://crates.io/crates/assert_cmd) 9 10`assert_cmd` aims to simplify the process for doing integration testing of CLIs, including: 11- Finding your crate's binary to test 12- Assert on the result of your program's run. 13 14## Install 15 16Add to your `Cargo.toml`: 17 18```toml 19[dependencies] 20assert_cmd = "1.0.2" 21``` 22 23## Example 24 25Here's a trivial example: 26 27```rust,no_run 28use assert_cmd::Command; 29 30let mut cmd = Command::cargo_bin("bin_fixture").unwrap(); 31cmd.assert().success(); 32``` 33 34See the [docs](http://docs.rs/assert_cmd) for more. 35 36## Relevant crates 37 38Other crates that might be useful in testing command line programs. 39* [escargot][escargot] for more control over configuring the crate's binary. 40* [duct][duct] for orchestrating multiple processes. 41 * or [commandspec] for easier writing of commands 42* [rexpect][rexpect] for testing interactive programs. 43* [`assert_fs`][assert_fs] for filesystem fixtures and assertions. 44 * or [tempfile][tempfile] for scratchpad directories. 45* [dir-diff][dir-diff] for testing file side-effects. 46 47[escargot]: http://docs.rs/escargot 48[rexpect]: https://crates.io/crates/rexpect 49[dir-diff]: https://crates.io/crates/dir-diff 50[tempfile]: https://crates.io/crates/tempfile 51[duct]: https://crates.io/crates/duct 52[assert_fs]: https://crates.io/crates/assert_fs 53[commandspec]: https://crates.io/crates/commandspec 54 55## License 56 57Licensed under either of 58 59 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 60 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 61 62at your option. 63 64### Testimonials 65 66fitzgen 67> assert_cmd is just such a pleasure to use every single time, I fall in love all over again 68> 69> bravo bravo WG-cli 70 71passcod 72> 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. 73 74volks73 75> I have used [assert_cmd] in other projects and I am extremely pleased with it 76 77coreyja 78> [assert_cmd] pretty much IS my testing strategy so far, though my app under test is pretty small. 79> 80> 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! 81 82### Contribution 83 84Unless you explicitly state otherwise, any contribution intentionally 85submitted for inclusion in the work by you, as defined in the Apache-2.0 86license, shall be dual licensed as above, without any additional terms or 87conditions. 88 89[Crates.io]: https://crates.io/crates/assert_cmd 90[Documentation]: https://docs.rs/assert_cmd 91