macro_rules! assert_err {
    ($e:expr) => { ... };
    ($e:expr,) => { ... };
    ($e:expr, $($arg:tt)+) => { ... };
}
Expand description

Asserts that the expression evaluates to Err and returns the error.

This will invoke the panic! macro if the provided expression does not evaluate to Err at runtime.

§Custom Messages

This macro has a second form, where a custom panic message can be provided with or without arguments for formatting.

§Examples

use tokio_test::assert_err;
use std::str::FromStr;


let err = assert_err!(u32::from_str("fail"));

let msg = "fail";
let err = assert_err!(u32::from_str(msg), "testing parsing {:?} as u32", msg);