Created
August 21, 2022 18:29
-
-
Save otaviocc/00af82bf750b581ba9b065f0bad0b4ef to your computer and use it in GitHub Desktop.
XCTestCase Wait Until
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension XCTestCase { | |
func waitUntil( | |
timeout: TimeInterval = 1, | |
isInverted: Bool = false, | |
fulfillmentCount: Int = 1, | |
block: @escaping (@escaping () -> Void) -> Void | |
) { | |
let expectation = expectation( | |
description: "isInverted: \(isInverted), fulfillmentCount: \(fulfillmentCount)" | |
) | |
expectation.isInverted = isInverted | |
expectation.expectedFulfillmentCount = fulfillmentCount | |
block(expectation.fulfill) | |
wait(for: [expectation], timeout: timeout) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment