use assert_cmd::prelude::*; use predicates::prelude::*; use std::process::Command; #[test] // A Basic Smoke Test fn run_with_defaults() -> Result<(), Box> { Command::cargo_bin("catsay-ag") .expect("binary exists") .assert() .success() .stdout(predicate::str::contains("Meow!")); Ok(()) } // Check that a Bad Argument Triggers a Failure #[test] fn fail_on_non_existing_file() -> Result<(), Box> { Command::cargo_bin("catsay-ag") .expect("binary exists") .args(&["-f", "no/such/file.txt"]) .assert() .failure(); Ok(()) } /* 1. A Basic Smoke Test ag@mbp:~/src-rs/pract-rust-proj/cli/catsay-ag $ cargo test Compiling catsay-ag v0.1.0 (/Users/ag/src-rs/pract-rust-proj/cli/catsay-ag) Finished test [unoptimized + debuginfo] target(s) in 2.41s Running target/debug/deps/catsay_ag-946b57914af2f7a9 running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out Running target/debug/deps/integration_test-b2f9493b6808e29c running 1 test test run_with_defaults ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out */ /* 2. Check that the STDOUT Contains a Certain String ag@mbp:~/src-rs/pract-rust-proj/cli/catsay-ag $ cargo test Compiling catsay-ag v0.1.0 (/Users/ag/src-rs/pract-rust-proj/cli/catsay-ag) Finished test [unoptimized + debuginfo] target(s) in 3.68s Running target/debug/deps/catsay_ag-946b57914af2f7a9 running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out Running target/debug/deps/integration_test-b2f9493b6808e29c running 2 tests test fail_on_non_existing_file ... ok test run_with_defaults ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ag@mbp:~/src-rs/pract-rust-proj/cli/catsay-ag$ */