Function loggy::assert_errors
source · pub fn assert_errors<Code: FnOnce() -> Result, Result>(
scope: &str,
expected_log: &str,
code: Code
)
Expand description
Similar to assert_logs_panics
, asserting that the code
will generate one or more error messages, which will
trigger a panic at the end of the scope
.
Notes
The rust log
facade mandates using a single global logger. Therefore, only one test can capture the log at any
given time, using a global Mutex
. Therefore, nesting this inside itself, assert_panics
or
assert_logs_panics
will deadlock.
Panics
If the code does generate the expected log, or the log does not contain errors (so the code does not panic).