diff --git a/Sources/Nimble/DSL+Wait.swift b/Sources/Nimble/DSL+Wait.swift index a84682f94..e8741368e 100644 --- a/Sources/Nimble/DSL+Wait.swift +++ b/Sources/Nimble/DSL+Wait.swift @@ -111,6 +111,6 @@ internal func blockedRunLoopErrorMessageFor(_ fnName: String, leeway: TimeInterv /// /// This function manages the main run loop (`NSRunLoop.mainRunLoop()`) while this function /// is executing. Any attempts to touch the run loop may cause non-deterministic behavior. -public func waitUntil(timeout: TimeInterval = 1, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) -> Void) { +public func waitUntil(timeout: TimeInterval = AsyncDefaults.Timeout, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) -> Void) { NMBWait.until(timeout: timeout, file: file, line: line, action: action) } diff --git a/Tests/NimbleTests/AsynchronousTest.swift b/Tests/NimbleTests/AsynchronousTest.swift index 46e34ce67..c44b9e688 100644 --- a/Tests/NimbleTests/AsynchronousTest.swift +++ b/Tests/NimbleTests/AsynchronousTest.swift @@ -8,6 +8,7 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { return [ ("testToEventuallyPositiveMatches", testToEventuallyPositiveMatches), ("testToEventuallyNegativeMatches", testToEventuallyNegativeMatches), + ("testWaitUntilWithCustomDefaultsTimeout", testWaitUntilWithCustomDefaultsTimeout), ("testWaitUntilPositiveMatches", testWaitUntilPositiveMatches), ("testToEventuallyWithCustomDefaultTimeout", testToEventuallyWithCustomDefaultTimeout), ("testWaitUntilTimesOutIfNotCalled", testWaitUntilTimesOutIfNotCalled), @@ -86,6 +87,17 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { expect { value }.toEventuallyNot(equal(1)) } + func testWaitUntilWithCustomDefaultsTimeout() { + AsyncDefaults.Timeout = 5 + defer { + AsyncDefaults.Timeout = 1 + } + waitUntil { done in + Thread.sleep(forTimeInterval: 4.8) + done() + } + } + func testWaitUntilPositiveMatches() { waitUntil { done in done()