Contents

fulfillment(of:timeout:enforceOrder:)

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

Declaration

@nonobjc class func fulfillment(of expectations: [XCTestExpectation], timeout seconds: TimeInterval = .infinity, enforceOrder enforceOrderOfFulfillment: Bool = false) async -> XCTWaiter.Result

Parameters

  • expectations:

    An array of expectations the test must satisfy.

  • seconds:

    The time, in seconds, the test allows for the fulfillment of the expectations.

  • enforceOrderOfFulfillment:

    If True, the test must satisfy the expectations in the order they appear in the array.

Return Value

A value describing the outcome of waiting for expectations.

Discussion

Use this Concurrency safe alternative to wait(for:timeout:enforceOrder:) in your Swift code. A call to wait(for:timeout:enforceOrder:) runs synchronously and blocks the calling thread, which can cause deadlocks or priority inversion.

Expectations can only appear in the array once. The call may return before the timeout if the test fulfills all the expectations you provide.

The test discards the waiter after the wait completes.

See Also

Waiting for Expectations