Quick / Nimble

A Matcher Framework for Swift and Objective-C
https://quick.github.io/Nimble/documentation/nimble/
Apache License 2.0
4.81k stars 598 forks source link

Where to set the global timeout? #1021

Closed wrightak closed 1 year ago

wrightak commented 1 year ago

I would like to increase the global timeout on CI. Xcode Cloud seems to use slow machines, or at least they seem to perform slowly. I know that I can do this by using this code:

// Increase the global timeout to 5 seconds:
Nimble.AsyncDefaults.timeout = .seconds(5)

// Slow the polling interval to 0.1 seconds:
Nimble.AsyncDefaults.pollInterval = .milliseconds(100)

My question is: is there a recommendation on where should this be set? If I do it in one of the tests, I don't know that this test will be the first to be executed.

younata commented 1 year ago

If you're using Quick, we recommend creating a QuickConfiguration subclass to do this in.

If you're using XCTest, you can create an XCTestObservation implementation, and configure your async defaults in testBundleWillStart(_:). You will also need to add that XCTestObservation object to XCTestObservationCenter.

Hope that helps!

wrightak commented 1 year ago

@younata That helps a lot! Great answer, thank you. Would it be helpful if I created a PR to add this to the README?

younata commented 1 year ago

@wrightak Appreciate the offer! I already took care of it, though. https://github.com/Quick/Nimble/pull/1022