After / delay with verify
Hello,
Is there an option in Cuckoo to use after or other delay option with matcher? Something similar to: VerificationAfterDelay
For now I combined it with expectations but I am not sure whether it's the best way.
func test() {
let exp = expectation(description: "testShow")
exp.expectedFulfillmentCount = 1
delay(1.0) { // async after
verify(view).show()
exp.fulfill() // always fulfill
}
wait(for: [exp], timeout: 2.0)
}
USE CASE:
I wanted to test whether some methods were invoked in Presenter which used Timer. I could of course mock this Timer as it is usually done with API requests but for such simple scenario I think delay in verify would be better.
Regards
Hey there, at the moment Cuckoo does not support these async matchers.
It's something that I can imagine is used often, as others have already asked. However, at the moment our greatest priority is generics support.
Though you can implement this functionality if you're up for it and submit a PR. It will probably need to be a part of Cuckoo sooner or later.
@MatyasKriz I submitted a PR(#434). This PR is a prototype, so I haven't written any comments, tests, etc. If this PR is acceptable, I will write comments, tests and explanation to README.md. If there are any improvements, please point them out.
@sk409 @MatyasKriz any news on this topic? :)
Yeah, some time ago I reviewed the PR but didn't publish the comments. When I got to the PR again, I was unsure if the comments were valid, so I'll have to do another review round.