Issue #644

import XCTest

extension XCTestCase {
    /// Asynchronously assertion
    func XCTAssertWait(
        timeout: TimeInterval = 1,
        _ expression: @escaping () -> Void,
        _: String = "",
        file _: StaticString = #file,
        line _: UInt = #line
    ) {
        let expectation = self.expectation(description: #function)
        DispatchQueue.main.asyncAfter(deadline: .now() + timeout) {
            expression()
            expectation.fulfill()
        }

        let waiter = XCTWaiter()
        XCTAssertTrue(waiter.wait(for: [expectation], timeout: timeout + 1) == .completed)
    }
}

Updated at 2020-04-28 09:23:59