use mockers::Scenario; use mockers_derive::mocked; #[test] fn test_async_method() { #[mocked(TraitMock)] trait Trait { async fn foo(&self) -> u32; } let scenario = Scenario::new(); let (mock, handle) = scenario.create_mock::(); scenario.expect(handle.foo().and_return(Box::new(async { dbg!(20) }))); // Trait's 'async fn' may only be implemented with 'async fn' and not regular function // returning future. And body of async function is only run on first poll. So call .await. let _ = tokio_test::block_on(mock.foo()); }