Using Mockito in async tests
masterMockito provides an asynchronous interface for use in async runtimes like tokio. When writing async tests, ensure you use the _async variants of the methods:
Server::new_async().awaitto create the server..create_async().awaitto create the mock.Mock::assert_async().awaitto verify the mock was called.
Example:
#[tokio::test]
async fn test_simple_route_mock_async() {
let mut server = Server::new_async().await;
let m1 = server.mock("GET", "/a").with_body("aaa").create_async().await;
let m2 = server.mock("GET", "/b").with_body("bbb").create_async().await;
let (m1, m2) = futures::join!(m1, m2);
// You can use `Mock::assert_async` to verify that your mock was called
// m1.assert_async().await;
// m2.assert_async().await;
}