Crate assert_call

Source
Expand description

A tool for testing that ensures code parts are called as expected.

By creating an instance of CallRecorder, it starts recording the calls to call, and then CallRecorder::verify verifies that the calls to call are as expected.

The pattern of expected calls specified in CallRecorder::verify uses Call.

§Examples

use assert_call::{call, CallRecorder};

let mut c = CallRecorder::new();

call!("1");
call!("2");

c.verify(["1", "3"]);

The above code panics and outputs the following message because the call to call macro is different from what is specified in CallRecorder::verify.

actual calls :
  1
* 2
  (end)

mismatch call
src\lib.rs:10
actual : 2
expect : 3

§Backtrace support

If backtrace capture is enabled at Backtrace::capture, CallRecorder::verify outputs detailed information including the backtrace for each call! call.

Modules§

records

Macros§

call
Record the call.

Structs§

CallRecorder
Records and verifies calls to call.

Enums§

Call
Pattern of expected call calls.

Traits§

ToCall
Types convertible to Call.