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 append_context<D>(self, name: &'static str, context: D) -> Self where
D: Display + 'static,
[src]
pub fn append_context<D>(self, name: &'static str, context: D) -> Self where
D: Display + 'static,
Clarify failures with additional context.
Examples
use assert_cmd::prelude::*; use std::process::Command; Command::main_binary() .unwrap() .assert() .append_context("main", "no args") .success();
pub fn get_output(&self) -> &Output
[src]
pub fn get_output(&self) -> &Output
Access the contained 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
ⓘThis example is not tested
use assert_cmd::prelude::*; use std::process::Command; use predicates::prelude::*; Command::main_binary() .unwrap() .env("exit", "42") .assert() .code(predicate::eq(42)); // which can be shortened to: Command::main_binary() .unwrap() .env("exit", "42") .assert() .code(42);
- See
predicates::prelude
for more predicates. - See
IntoCodePredicate
for other built-in conversions.
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
ⓘThis example is not tested
use assert_cmd::prelude::*; use std::process::Command; use predicates::prelude::*; Command::main_binary() .unwrap() .env("stdout", "hello") .env("stderr", "world") .assert() .stdout(predicate::str::similar("hello\n").from_utf8()); // which can be shortened to: Command::main_binary() .unwrap() .env("stdout", "hello") .env("stderr", "world") .assert() .stdout("hello\n");
- See
predicates::prelude
for more predicates. - See
IntoOutputPredicate
for other built-in conversions.
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
ⓘThis example is not tested
use assert_cmd::prelude::*; use std::process::Command; use predicates::prelude::*; Command::main_binary() .unwrap() .env("stdout", "hello") .env("stderr", "world") .assert() .stderr(predicate::str::similar("world\n").from_utf8()); // which can be shortened to: Command::main_binary() .unwrap() .env("stdout", "hello") .env("stderr", "world") .assert() .stderr("world\n");
- See
predicates::prelude
for more predicates. - See
IntoOutputPredicate
for other built-in conversions.
Trait Implementations
impl Display for Assert
[src]
impl Display 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 Debug for Assert
[src]
impl Debug for Assert