use std::process::Command; use assert_cmd::prelude::*; use assert_fs::prelude::FileWriteStr; // Add methods on commands use predicates::prelude::*; #[test] fn file_doesnt_exist() -> Result<(), Box>{ let mut cmd = Command::cargo_bin("neteye-tool-grrs")?; cmd.arg("main").arg("src/main.rss"); cmd.assert() .failure() .stderr(predicate::str::contains("could not read file")); Ok(()) } #[test] fn find_content_in_file()->Result<(),Box>{ let file = assert_fs::NamedTempFile::new("sample.txt")?; file.write_str("A test\nActual content\nMore content\nAnother test")?; let mut cmd = Command::cargo_bin("grrs")?; cmd.arg("test").arg(file.path()); cmd.assert().failure().stdout(predicate::str::contains("test\nAnother test")); Ok(()) }