<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTWaiter",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTWaiter"
  },
  "title" : "XCTWaiter"
}
-->

# XCTWaiter

Waits for the fulfillment of a group of expectations.

```
class XCTWaiter
```

## Overview

You can use waiters with or without a delegate to respond to events such as completion, timeout, or invalid expectation fulfillment. [`XCTestCase`](/documentation/XCTest/XCTestCase) automatically conforms to the [`XCTWaiterDelegate`](/documentation/XCTest/XCTWaiterDelegate) protocol and automatically reports timeouts and other unexpected events as test failures.

You can use waiters 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

[`-  initWithDelegate:`](/documentation/XCTest/XCTWaiter/init(delegate:))

Creates a new waiter with the specified delegate.

### Waiting for Expectations

[`fulfillment(of:timeout:enforceOrder:)`](/documentation/XCTest/XCTWaiter/fulfillment(of:timeout:enforceOrder:)-swift.method)

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

[`-  waitForExpectations:`](/documentation/XCTest/XCTWaiter/wait(for:)-swift.method)

Waits on a group of expectations.

[`-  waitForExpectations:enforceOrder:`](/documentation/XCTest/XCTWaiter/wait(for:enforceOrder:)-swift.method)

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

[`-  waitForExpectations:timeout:`](/documentation/XCTest/XCTWaiter/wait(for:timeout:)-swift.method)

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

[`-  waitForExpectations:timeout:enforceOrder:`](/documentation/XCTest/XCTWaiter/wait(for:timeout:enforceOrder:)-swift.method)

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

[`fulfillment(of:timeout:enforceOrder:)`](/documentation/XCTest/XCTWaiter/fulfillment(of:timeout:enforceOrder:)-swift.type.method)

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

[`+  waitForExpectations:`](/documentation/XCTest/XCTWaiter/wait(for:)-swift.type.method)

Creates a waiter that waits on a group of expectations.

[`+  waitForExpectations:enforceOrder:`](/documentation/XCTest/XCTWaiter/wait(for:enforceOrder:)-swift.type.method)

Creates a waiter that waits on a group of expectations optionally enforcing their order of fulfillment.

[`+  waitForExpectations:timeout:`](/documentation/XCTest/XCTWaiter/wait(for:timeout:)-swift.type.method)

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

[`+  waitForExpectations:timeout:enforceOrder:`](/documentation/XCTest/XCTWaiter/wait(for:timeout:enforceOrder:)-swift.type.method)

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

[`Result`](/documentation/XCTest/XCTWaiter/Result)

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

### Responding to Expectation Fulfilment

[`delegate`](/documentation/XCTest/XCTWaiter/delegate)

The delegate to which expectation fulfillment events will be reported.

[`XCTWaiterDelegate`](/documentation/XCTest/XCTWaiterDelegate)

Defines methods that are called when [`XCTWaiter`](/documentation/XCTest/XCTWaiter) expectations are fulfilled correctly or incorrectly.

[`fulfilledExpectations`](/documentation/XCTest/XCTWaiter/fulfilledExpectations)

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

## Relationships

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Sendable`](/documentation/Swift/Sendable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)