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

# wait(for:enforceOrder:)

Waits on a group of expectations optionally enforcing their order of fulfillment.

## Declaration

```swift
func wait(for expectations: [XCTestExpectation], enforceOrder enforceOrderOfFulfillment: Bool)
```

## Parameters

- `expectations`: An array of expectations the test must satisfy.
- `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:timeout:)](xctest/xctestcase/wait(for:timeout:).md)
- [wait(for:timeout:enforceOrder:)](xctest/xctestcase/wait(for:timeout:enforceorder:).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)
