How to call async functions in tests

I'm writing a test that needs to call async function before asserting on result.
Test looks something like this:

#[cfg(test)]
mod test {
  #[tokio::test]
  async fn test_foo() {
    let foo = make_foo().await.expect("Error making foo");
    assert_eq(foo, 1);
  }
}

I keep getting this error:

there is no timer running, must be called from the context of Tokio runtime

What am I missing here?

1 Like

You've probably used Tokio 0.3 with a library that expects Tokio 0.2.

1 Like

You are absolutely right. :see_no_evil:
Thank you!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.