<!--
{
  "availability" : [

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

# XCTestExpectation

An expected outcome in an asynchronous test.

```
class XCTestExpectation
```

## Topics

### Creating Expectations

[`-  initWithDescription:`](/documentation/XCTest/XCTestExpectation/init(description:))

Creates a new [`XCTestExpectation`](/documentation/XCTest/XCTestExpectation) with the provided description.

[`expectationDescription`](/documentation/XCTest/XCTestExpectation/expectationDescription)

A human readable string used to describe the expectation in log output and test reports.

### Fulfilling Expectations

[`-  fulfill`](/documentation/XCTest/XCTestExpectation/fulfill())

Marks the expectation as having been met.

### Fulfillment Count

[`expectedFulfillmentCount`](/documentation/XCTest/XCTestExpectation/expectedFulfillmentCount)

The number of times [`fulfill()`](/documentation/XCTest/XCTestExpectation/fulfill()) must be called before the expectation is completely fulfilled.

[`assertForOverFulfill`](/documentation/XCTest/XCTestExpectation/assertForOverFulfill)

Indicates that an assertion should be triggered during testing if the expectation is over-fulfilled.

### Unintended Expectations

[`inverted`](/documentation/XCTest/XCTestExpectation/isInverted)

Indicates that the expectation is not intended to happen.

## Relationships

### Inherited By

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

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

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

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

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

### Conforms To

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

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

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

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

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

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

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

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

### 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)