How to initialize the logger for integration tests?

You can use something like this:

use std::sync::Once;

static INIT: Once = Once::new();

/// Setup function that is only run once, even if called multiple times.
fn setup() {
    INIT.call_once(|| {

Then simply call setup() in the beginning of each test.

Originally based on this blogpost.

Leave a Comment