There is nothing special about the tests. These are “just” functions that run on multiple threads. Therefore, one solution does the same thing as in other code: create a global mutable singleton :
#[macro_use]
extern crate lazy_static;
lazy_static! {
static ref DATABASE: String = {
format!("{}{}", "This was", " expensive")
};
}
#[test]
fn one() {
println!("{}", *DATABASE);
}
#[test]
fn two() {
println!("{}", *DATABASE);
}
"", . , Drop lazy_static .