Created
May 9, 2017 22:42
-
-
Save sundeepgupta/494e5a5ed3ed04fa7032b9671048182a to your computer and use it in GitHub Desktop.
Async testing technique with semaphores based on http://stackoverflow.com/a/28285276/1672161
This file contains 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
let semaphore = DispatchSemaphore(value: 0) | |
asyncFunction() { result in | |
XCTAssert(result) | |
semaphore.signal | |
} | |
while semaphore.wait(timeout: .now()) == .timedOut { | |
RunLoop.current.run(until: Date(timeIntervalSinceNow: 3)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment