An async_test
macro for running async fn
tests.
It is part of safina
, a safe async runtime.
safina_executor
safina_timer::start_timer_thread
before running the testforbid(unsafe_code)
stable
requires once_cell
crate which contains some unsafe code.
This is necessary until
std::lazy::OnceCell
is stable.```rust use safinaasynctest::async_test;
async fn test1() { async_work().await.unwrap(); } ```
```rust use safinaasynctest::async_test;
// Make your test an async fn
.
async fn test2() {
// You can await
.
async_work().await.unwrap();
// You can spawn tasks which will run on
// the executor.
// These tasks stop when the test
// function returns and drops the
// executor.
safina_executor::spawn(background_task());
// You can run blocking code without
// stalling other async tasks.
let result = safina_executor::schedule_blocking(
|| blocking_work()
).async_recv().await.unwrap();
assert_eq!(3, result.unwrap());
// You can use timer functions.
safina_timer::sleep_for(
Duration::from_millis(10)).await;
safina_timer::with_timeout(
async_work(),
Duration::from_millis(100)
).await.unwrap();
} ```
https://docs.rs/safina-async-test
safina-executor
v0.3.1.safina-executor
v0.3.0.safina-executor
v0.2.0.safina-executor
and
safina-timer
crates.once_cell
.safina-timer
threadsafina-executor
v0.1.3 APIsafina-executor
version which removes need for Box::pin
.safina
package to
safina-executor
.Cargo.toml
and bump version number../release.sh
License: Apache-2.0