pub trait TestResource: Sized {
// Required methods
fn setup() -> Self;
fn teardown(&mut self);
}Expand description
Per-test resource with setup and teardown hooks
Implement this trait to define test resources that need initialization before each test and cleanup after each test.
§Examples
use reinhardt_testkit::resource::TestResource;
struct TestEnv {
data: Vec<String>,
}
impl TestResource for TestEnv {
fn setup() -> Self {
Self { data: vec![] }
}
fn teardown(&mut self) {
self.data.clear();
}
}Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".