---
title: "wait(for:timeout:enforceOrder:)"
framework: xctest
role: symbol
role_heading: Instance Method
path: "xctest/xctestcase/wait(for:timeout:enforceorder:)"
---

# 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

```swift
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 doc://com.apple.documentation/documentation/Swift/true, the test must satisfy the expectations in the order they appear in the array.

## Discussion

Discussion note: Use fulfillment(of:timeout:enforceOrder:) in Swift code requiring concurrency. 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.

## See Also

### Waiting for Expectations

- [fulfillment(of:timeout:enforceOrder:)](xctest/xctestcase/fulfillment(of:timeout:enforceorder:).md)
- [wait(for:)](xctest/xctestcase/wait(for:).md)
- [wait(for:enforceOrder:)](xctest/xctestcase/wait(for:enforceorder:).md)
- [wait(for:timeout:)](xctest/xctestcase/wait(for:timeout:).md)
- [waitForExpectations(timeout:handler:)](xctest/xctestcase/waitforexpectations(timeout:handler:).md)
- [XCWaitCompletionHandler](xctest/xcwaitcompletionhandler.md)
- [XCTestError](xctest/xctesterror.md)
- [XCTestError.Code](xctest/xctesterror/code.md)
- [XCTestErrorDomain](xctest/xctesterrordomain.md)
