pub trait AsyncTestResource: Sized + Send {
// Required methods
fn setup<'async_trait>( ) -> Pin<Box<dyn Future<Output = Self> + Send + 'async_trait>>
where Self: 'async_trait;
fn teardown<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait;
}Expand description
Async version of TestResource for async setup/teardown
Implement this trait for test resources that require asynchronous initialization or cleanup.
§Examples
use reinhardt_testkit::resource::AsyncTestResource;
struct AsyncTestEnv {
connection: String,
}
#[async_trait::async_trait]
impl AsyncTestResource for AsyncTestEnv {
async fn setup() -> Self {
// Async initialization
Self { connection: "test_db".to_string() }
}
async fn teardown(self) {
// Async cleanup
}
}Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.