Struct assert_cmd::Assert [−][src]
pub struct Assert { /* fields omitted */ }Assert the state of an Output.
Create an Assert through the OutputAssertExt trait.
Examples
use assert_cmd::prelude::*; use std::process::Command; Command::main_binary() .unwrap() .assert() .success();
Methods
impl Assert[src]
impl Assertpub fn new(output: Output) -> Self[src]
pub fn new(output: Output) -> SelfCreate an Assert for a given Output.
pub fn set_cmd(self, cmd: String) -> Self[src]
pub fn set_cmd(self, cmd: String) -> SelfAdd the command line for additional context.
pub fn set_stdin(self, stdin: Vec<u8>) -> Self[src]
pub fn set_stdin(self, stdin: Vec<u8>) -> SelfAdd the stdn for additional context.
pub fn get_output(&self) -> &Output[src]
pub fn get_output(&self) -> &OutputAccess the contained std::process::Output.
pub fn success(self) -> Self[src]
pub fn success(self) -> SelfEnsure the command succeeded.
Examples
use assert_cmd::prelude::*; use std::process::Command; Command::main_binary() .unwrap() .assert() .success();
pub fn failure(self) -> Self[src]
pub fn failure(self) -> SelfEnsure the command failed.
Examples
use assert_cmd::prelude::*; use std::process::Command; Command::main_binary() .unwrap() .env("exit", "1") .assert() .failure();
pub fn interrupted(self) -> Self[src]
pub fn interrupted(self) -> SelfEnsure the command returned the expected code.
pub fn code<I, P>(self, pred: I) -> Self where
I: IntoCodePredicate<P>,
P: Predicate<i32>, [src]
pub fn code<I, P>(self, pred: I) -> Self where
I: IntoCodePredicate<P>,
P: Predicate<i32>, Ensure the command returned the expected code.
Examples
ⓘThis example is not tested
use assert_cmd::prelude::*; use std::process::Command; Command::main_binary() .unwrap() .env("exit", "42") .assert() .code(42); // which is equivalent to Command::main_binary() .unwrap() .env("exit", "42") .assert() .code(predicates::ord::eq(42));
pub fn stdout(self, pred: &Predicate<[u8]>) -> Self[src]
pub fn stdout(self, pred: &Predicate<[u8]>) -> SelfEnsure the command wrote the expected data to stdout.
Examples
ⓘThis example is not tested
use assert_cmd::prelude::*; use std::process::Command; Command::main_binary() .unwrap() .env("stdout", "hello") .env("stderr", "world") .assert() .stdout(predicates::ord::eq(b"hello"));
pub fn stderr(self, pred: &Predicate<[u8]>) -> Self[src]
pub fn stderr(self, pred: &Predicate<[u8]>) -> SelfEnsure the command wrote the expected data to stderr.
Examples
ⓘThis example is not tested
use assert_cmd::prelude::*; use std::process::Command; Command::main_binary() .unwrap() .env("stdout", "hello") .env("stderr", "world") .assert() .stderr(predicates::ord::eq(b"world"));
Trait Implementations
impl Debug for Assert[src]
impl Debug for Assertfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl Display for Assert[src]
impl Display for Assert