#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]
pub use futures;
pub use test_context_macros::test_context;
pub trait TestContext
where
Self: Sized,
{
fn setup() -> Self;
fn teardown(self) {}
}
pub trait AsyncTestContext
where
Self: Sized,
{
fn setup() -> impl std::future::Future<Output = Self> + Send;
fn teardown(self) -> impl std::future::Future<Output = ()> + Send {
async {}
}
}
impl<T> TestContext for T
where
T: AsyncTestContext + Send,
{
fn setup() -> Self {
futures::executor::block_on(<T as AsyncTestContext>::setup())
}
fn teardown(self) {
futures::executor::block_on(<T as AsyncTestContext>::teardown(self))
}
}