Class

XCTWaiter

Waits for a group of expectations to be fulfilled.

Overview

Waiters can be used with or without a delegate to respond to events such as completion, timeout, or invalid expectation fulfillment. XCTestCase automatically conforms to the XCTWaiterDelegate protocol and will automatically report timeouts and other unexpected events as test failures.

Waiters can be used without a delegate or any association with a test case instance. This allows test support libraries to provide convenience methods for waiting without having to pass test cases through those APIs.

Topics

Creating a Waiter

init(delegate: XCTWaiterDelegate?)

Creates a new waiter with the specified delegate.

Waiting for Expectations

func wait(for: [XCTestExpectation], timeout: TimeInterval)

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

func wait(for: [XCTestExpectation], timeout: TimeInterval, enforceOrder: Bool)

Waits on a group of expectations for up to the specified timeout, optionally enforcing their order of fulfillment.

class func wait(for: [XCTestExpectation], timeout: TimeInterval)

Creates a waiter that waits on a group of expectations for up to the specified timeout.

class func wait(for: [XCTestExpectation], timeout: TimeInterval, enforceOrder: Bool)

Creates a waiter that waits on a group of expectations for up to the specified timeout, optionally enforcing their order of fulfillment.

enum XCTWaiter.Result

Result states returned by a waiter when it completes, times out, fails, or is interrupted.

Responding to Expectation Fulfilment

var delegate: XCTWaiterDelegate?

The delegate to which expectation fulfillment events will be reported.

protocol XCTWaiterDelegate

Defines methods that are called when XCTWaiter expectations are fulfilled correctly or incorrectly.

var fulfilledExpectations: [XCTestExpectation]

An array of expectations that were fulfilled, in order, up until the waiter stopped waiting.

Relationships

Inherits From

Conforms To