use assert_cmd::prelude::*; use predicates::prelude::*; use std::process::Command; #[test] fn find_a_match() { let mut result = Vec::new(); exex::find_matches("lorem ipsum\ndolor sit amet", "lorem", &mut result); assert_eq!(result, b"lorem ipsum\n"); } #[test] fn file_doesnt_exist() -> Result<(), Box> { let mut cmd = Command::cargo_bin("exex")?; cmd.arg("foobar").arg("test/file/doesnt/exist"); cmd.assert() .failure() .stderr(predicate::str::contains("could not read file")); Ok(()) }