---
title: "expectation(description:)"
framework: xctest
role: symbol
role_heading: Instance Method
path: "xctest/xctestcase/expectation(description:)"
---

# expectation(description:)

Creates a new expectation with an associated description.

## Declaration

```swift
func expectation(description: String) -> XCTestExpectation
```

## Parameters

- `description`: A string to display in the test log for this expectation, to help diagnose failures.

## Discussion

Discussion Use this method to create XCTestExpectation instances that can be fulfilled when asynchronous tasks in your tests complete. To fulfill an expectation that was created with expectation(description:), call the expectation’s fulfill() method when the asynchronous task in your test has completed.

## See Also

### Creating Asynchronous Test Expectations

- [expectation(for:evaluatedWith:handler:)](xctest/xctestcase/expectation(for:evaluatedwith:handler:).md)
- [expectation(forNotification:object:handler:)](xctest/xctestcase/expectation(fornotification:object:handler:).md)
- [expectation(forNotification:object:notificationCenter:handler:)](xctest/xctestcase/expectation(fornotification:object:notificationcenter:handler:).md)
- [keyValueObservingExpectation(for:keyPath:expectedValue:)](xctest/xctestcase/keyvalueobservingexpectation(for:keypath:expectedvalue:).md)
- [expectation(that:on:options:willEqual:)](xctest/xctestcase/expectation(that:on:options:willequal:).md)
- [keyValueObservingExpectation(for:keyPath:handler:)](xctest/xctestcase/keyvalueobservingexpectation(for:keypath:handler:).md)
- [expectation(that:on:options:willSatisfy:)](xctest/xctestcase/expectation(that:on:options:willsatisfy:)-6itb.md)
- [expectation(that:on:options:willSatisfy:)](xctest/xctestcase/expectation(that:on:options:willsatisfy:)-292oj.md)
- [expectation(that:on:options:willSatisfy:)](xctest/xctestcase/expectation(that:on:options:willsatisfy:)-85or0.md)
