Crate expected

Source
Expand description

An assertion utility focused on unit testing.

This library provides the variant of assertion macros that does not panic and continues test cases whenever assertions are passed or not.

§Example

use expected::{expected, expect};

let name = "Alice";
let age = 14;

let ((), disappoints) = expected(|| {
    expect!(name == "Alice");
    expect!(age == 18);
    // ...
});

if let Some(disappoints) = disappoints {
    eprintln!("{}", disappoints);
}

!

Macros§

expect
Declare an expectation that the specified conditional expression is true.
expect_eq
Declare an expectation that the specified values are equal.

Structs§

Disappoint
A struct providing information about a disappointing expectation.
Disappoints
A set of Disappoints occurred during an execution of expected.
Expected
A future for the expected method.

Traits§

FutureExpectedExt
An extension trait for Futures that provides an adaptor for tracking that all expectations are satisfied.

Functions§

expected
Run the provided closure and checks to see if all expectation have been satisfied.