4 ms·
The lack of before all, before each, after each and after all is really something I miss every day in rust. You can replicate it partially with a OnceCell, a f
by Sytten 3y ago
The lack of before all, before each, after each and after all is really something I miss every day in rust.
You can replicate it partially with a OnceCell, a function call in each test and RAII but not ideal.
pub async fn test<T, U>(test: T)
where
T: FnOnce() -> U,
U: Future,
{
setup().await;
let result = async move { panic::AssertUnwindSafe(test()).catch_unwind().await }.await;
teardown().await;
assert!(result.is_ok())
}