use assert_cmd::prelude::*; // Add methods on commands use predicates::prelude::*; // Used for writing assertions use std::process::Command; // Run programs #[cfg(target_os = "macos")] #[test] fn test_cli_help() -> Result<(), Box> { let mut cmd = Command::cargo_bin("check_macos_updates")?; cmd.arg("--help"); cmd.assert() .code(predicate::eq(3)) .stdout(predicate::str::contains("Usage:")) .stdout(predicate::str::contains("Options:")); Ok(()) } #[cfg(target_os = "macos")] #[test] fn test_cli_version() -> Result<(), Box> { let mut cmd = Command::cargo_bin("check_macos_updates")?; cmd.arg("--version"); cmd.assert() .code(predicate::eq(3)) .stdout(predicate::str::contains(env!("CARGO_PKG_VERSION"))); Ok(()) }