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]

Create an Assert for a given Output.

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

Access the contained 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 aborted before returning a code.

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

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

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

Trait Implementations

impl Display for Assert
[src]

Formats the value using the given formatter. Read more

impl Debug for Assert
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl !Send for Assert

impl !Sync for Assert