Verifying async logic
DesmanLead opened this issue · 0 comments
DesmanLead commented
It's a common use-case to verify that the method will be called at some moment in the future in a given timeout.
It's possible to implement this using Perform
, but another version of Verify
(e.g. Expect
?) would be really handy.
So the API design might be as follows:
override func setUp() {
super.setUp()
interactor = MyInteractor()
interactor.service = mockService
}
func testThatInteractorHandlesRefresh() async throws {
// given
Given(mockService, .obtainData(...))
// when
await interactor.refresh() // calls obtainData asynchronously inside
// then
await Expect(mockService, .obtainData(...)) // default timeout
await Expect(mockService, .obtainData(...), timeout: .seconds(1))
}
What do you think? It doesn't look hard to implement, so you can just point the right spot to add this.