wait(for:timeout:enforceOrder:)
Waits for the test to satisfy an array of expectations and specifies whether they must occur in the array’s order.
Declaration
func wait(for expectations: [XCTestExpectation], timeout seconds: TimeInterval, enforceOrder enforceOrderOfFulfillment: Bool)Parameters
- expectations:
An array of expectations the test must satisfy.
- seconds:
The time, in seconds, the test allows for the fulfillment of the expectations. The default timeout allows the test to run until it reaches its execution time allowance.
- enforceOrderOfFulfillment:
If True, the test must satisfy the expectations in the order they appear in the array.
Discussion
In Objective-C code, you might use an expectation to wait on a call to an interface that uses a completion handler to return a result. From Swift code, consider calling withCheckedContinuation(function:_:) to use Concurrency instead of an expectation to wait on the result of a completion handler.