Instance Method

waitForExpectationsWithTimeout:handler:

Waits until all expectations are fulfilled or the timeout is reached.

Declaration

- (void)waitForExpectationsWithTimeout:(NSTimeInterval)timeout handler:(XCWaitCompletionHandler)handler;

Parameters

timeout

The amount of time within which all expectations must be fulfilled.

handler

An optional XCWaitCompletionHandler block to invoke when all expectations have been fulfilled or when the wait timeout is triggered. (Timeout is always treated as a test failure.)

Discussion

This method creates a point of synchronization in the flow of a test. Only one waitForExpectationsWithTimeout:handler: can be active at any given time, but multiple discrete sequences of “create expectations and wait for them to be fulfilled” can be chained together.

See Also

Waiting for Expectations

- waitForExpectations:timeout:

Waits on a group of expectations for up to the specified timeout.

- waitForExpectations:timeout:enforceOrder:

Waits on an array of expectations and specifies whether they must be fulfilled in the given order.

XCWaitCompletionHandler

A block to be called when a call to waitForExpectationsWithTimeout:handler: has all of its expectations fulfilled, or times out.

XCTestErrorCode

Error codes for errors that can occur while waiting for expectations to be fulfilled.

XCTestErrorDomain

Error domain for errors that can occur while waiting for expectations to be fulfilled.