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(|| {
env_logger::init().unwrap();
});
}
Then simply call setup()
in the beginning of each test.
Originally based on this blogpost.