in Sources/XCTest/Public/XCTestCase.swift [337:358]
func awaitUsingExpectation(
_ closure: @escaping () async throws -> Void
) throws -> Void {
let expectation = XCTestExpectation(description: "async test completion")
let thrownErrorWrapper = ThrownErrorWrapper()
Task {
defer { expectation.fulfill() }
do {
try await closure()
} catch {
thrownErrorWrapper.error = error
}
}
_ = XCTWaiter.wait(for: [expectation], timeout: asyncTestTimeout)
if let error = thrownErrorWrapper.error {
throw error
}
}