A macro for running async fn
tests.
It is part of safina
, a safe async runtime.
Runs tests with safina_executor::block_on
.
forbid(unsafe_code)
stable
requires the feature once_cell
.
This uses once_cell
crate
which contains some unsafe code.
This is necessary until
std::lazy::OnceCell
is stable.safina-executor
.```rust use safinaasynctest::async_test;
async fn test1() { anasyncfn().await.unwrap(); } ```
```rust use safinaasynctest::async_test;
async fn test2() {
// Make your test an async fn
and await in it.
asserteq!(42, dorequest().await.unwrap());
// The macro creates an Executor and runs the test through it.
// You can spawn async tasks on it:
safina_executor::spawn(background_task());
// You can schedule blocking jobs to run on the Executor:
let result = safina_executor::schedule_blocking(|| blocking_work());
assert_eq!(3, result.await.unwrap());
// The macro also starts the timer thread, so this works:
safina_timer::sleep_for(Duration::from_millis(10)).await;
} ```
https://docs.rs/safina-async-test
once_cell
.safina-timer
threadsafina-executor
v0.1.3 APIsafina-executor
version which removes need for Box::pin
.safina
package to
safina-executor
.safina_async_test
re-export the macro and safina_executor::block_on
.safina_async_test::block_on
.Cargo.toml
and bump version number../release.sh
License: Apache-2.0