Skip to main content

check_and_clear

Function check_and_clear 

Source
pub fn check_and_clear(tracker: &TestTracker, expected: &[&str])
Expand description

Check and clear the trace and log output

This function asserts that the logging output lines seen since the start or the last time this function was called are expected. The test_init must have been called before this function can be used.

It then also clears both the trace and log output recorded so far.

§Arguments

  • tracker - A reference to the TestTracker being used in the test. This will have been keeping track of the trace and log events seen since it was created or last cleared.
  • expected - An array of expected regular expressions that the logging output will be matched against.

§Examples

use gwr_track::test_helpers;
use serial_test::serial;

#[test]
fn smoke() {
    let (test_tracker, tracker) = gwr_track::test_init!(20);
    let top = gwr_track::entity::toplevel(&tracker, "top");
    let id = gwr_track::create_id!(top);
    test_helpers::check_and_clear(&test_tracker, &["20: top created"]);
}