Struct assert_cmd::assert::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 Assert
pub fn new(output: Output) -> Self
[src]
pub fn new(output: Output) -> Self
Create an Assert
for a given Output
.
pub fn set_cmd(self, cmd: String) -> Self
[src]
pub fn set_cmd(self, cmd: String) -> Self
Add the command line for additional context.
pub fn set_stdin(self, stdin: Vec<u8>) -> Self
[src]
pub fn set_stdin(self, stdin: Vec<u8>) -> Self
Add the stdn
for additional context.
pub fn get_output(&self) -> &Output
[src]
pub fn get_output(&self) -> &Output
Access the contained std::process::Output
.
pub fn success(self) -> Self
[src]
pub fn success(self) -> Self
Ensure 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) -> Self
Ensure 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) -> Self
Ensure the command aborted before returning a 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
use assert_cmd::prelude::*; use std::process::Command; Command::main_binary() .unwrap() .env("exit", "42") .assert() .code(42);
pub fn stdout<I, P>(self, pred: I) -> Self where
I: IntoOutputPredicate<P>,
P: Predicate<[u8]>,
[src]
pub fn stdout<I, P>(self, pred: I) -> Self where
I: IntoOutputPredicate<P>,
P: Predicate<[u8]>,
Ensure the command wrote the expected data to stdout
.
Examples
use assert_cmd::prelude::*; use std::process::Command; Command::main_binary() .unwrap() .env("stdout", "hello") .env("stderr", "world") .assert() .stdout("hello\n");
pub fn stderr<I, P>(self, pred: I) -> Self where
I: IntoOutputPredicate<P>,
P: Predicate<[u8]>,
[src]
pub fn stderr<I, P>(self, pred: I) -> Self where
I: IntoOutputPredicate<P>,
P: Predicate<[u8]>,
Ensure the command wrote the expected data to stderr
.
Examples
use assert_cmd::prelude::*; use std::process::Command; Command::main_binary() .unwrap() .env("stdout", "hello") .env("stderr", "world") .assert() .stderr("world\n");
Trait Implementations
impl Debug for Assert
[src]
impl Debug for Assert
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Display for Assert
[src]
impl Display for Assert