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]

Create an Assert for a given Output.

Add the command line for additional context.

Add the stdn for additional context.

Access the contained std::process::Output.

Ensure the command succeeded.

Examples

use assert_cmd::prelude::*;

use std::process::Command;

Command::main_binary()
    .unwrap()
    .assert()
    .success();

Ensure the command failed.

Examples

use assert_cmd::prelude::*;

use std::process::Command;

Command::main_binary()
    .unwrap()
    .env("exit", "1")
    .assert()
    .failure();

Ensure the command returned the expected code.

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));

Ensure 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"));

Ensure 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]

Formats the value using the given formatter. Read more

impl Display for Assert
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Assert

impl Sync for Assert