Cuckoo icon indicating copy to clipboard operation
Cuckoo copied to clipboard

After / delay with verify

Open Ufosek opened this issue 6 years ago • 4 comments

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

Ufosek avatar May 09 '19 18:05 Ufosek

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 avatar May 10 '19 11:05 MatyasKriz

@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 avatar Sep 03 '22 09:09 sk409

@sk409 @MatyasKriz any news on this topic? :)

andreasziegl avatar Jan 18 '23 11:01 andreasziegl

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.

MatyasKriz avatar Jan 18 '23 17:01 MatyasKriz