Function loggy::assert_logs_panics

source ·
pub fn assert_logs_panics<Code: FnOnce() -> Result, Result>(
    expected_log: &str,
    expected_panic: &str,
    code: Code
)
Expand description

Combine assert_logs and assert_panics, that is, assert that the expected log is generated and then the expected panic is triggered.

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 does not panic, or panics with a different message than expected.