<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTestCase/wait(for:enforceOrder:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTestCase(im)waitForExpectations:enforceOrder:"
  },
  "title" : "wait(for:enforceOrder:)"
}
-->

# wait(for:enforceOrder:)

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

```
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

> Note:
> Use ``doc://com.apple.xctest/documentation/XCTest/XCTWaiter/fulfillment(of:timeout:enforceOrder:)-swift.method`` 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 <doc://com.apple.documentation/documentation/Swift/concurrency> instead of an expectation to wait on the result of a completion handler.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)