---
title: XCWaitCompletionHandler
framework: xctest
role: symbol
role_heading: Type Alias
path: xctest/xcwaitcompletionhandler
---

# XCWaitCompletionHandler

A block the test runner calls when the test fulfills a waiter’s expectations, or when it times out.

## Declaration

```swift
typealias XCWaitCompletionHandler = ((any Error)?) -> Void
```

## Parameters

- `error`: The error the waiter object encountered while waiting, which can be a timeout or a failure. See doc://com.apple.xctest/documentation/XCTest/XCTestError/Code for a list of possible errors.

## Discussion

Discussion Pass a block with this signature to waitForExpectations(timeout:handler:). Your block should handle any errors the waiter object encounters, including a timeout, and should perform assertions when the test fulfills the expectation for the waiter object.

## 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)
- [wait(for:timeout:enforceOrder:)](xctest/xctestcase/wait(for:timeout:enforceorder:).md)
- [waitForExpectations(timeout:handler:)](xctest/xctestcase/waitforexpectations(timeout:handler:).md)
- [XCTestError](xctest/xctesterror.md)
- [XCTestError.Code](xctest/xctesterror/code.md)
- [XCTestErrorDomain](xctest/xctesterrordomain.md)
