---
title: XCTKeyPathExpectation
framework: xctest
role: symbol
role_heading: Class
path: xctest/xctkeypathexpectation
---

# XCTKeyPathExpectation

An expectation that a specific key-value observing (KVO) condition fulfills.

## Declaration

```swift
final class XCTKeyPathExpectation<T, V> where T : NSObject
```

## Overview

Overview Use an instance of this class to asynchronously wait for changes to a property you specify by key path for a given object. When the value of the property changes, the expectation compares the new value using a predicate or expected value you provide.

## Topics

### Creating key path expectations

- [init(keyPath:observedObject:options:expectedValue:)](xctest/xctkeypathexpectation/init(keypath:observedobject:options:expectedvalue:).md)
- [init(keyPath:observedObject:options:predicate:)](xctest/xctkeypathexpectation/init(keypath:observedobject:options:predicate:).md)
- [init(keyPath:observedObject:options:filter:)](xctest/xctkeypathexpectation/init(keypath:observedobject:options:filter:)-plka.md)
- [init(keyPath:observedObject:options:filter:)](xctest/xctkeypathexpectation/init(keypath:observedobject:options:filter:)-8noag.md)
- [XCTKeyPathExpectation.AsynchronousFilter](xctest/xctkeypathexpectation/asynchronousfilter.md)
- [XCTKeyPathExpectation.SynchronousFilter](xctest/xctkeypathexpectation/synchronousfilter.md)
- [XCTKeyPathExpectation.Predicate](xctest/xctkeypathexpectation/predicate.md)

### Expectation properties

- [keyPath](xctest/xctkeypathexpectation/keypath.md)
- [observedObject](xctest/xctkeypathexpectation/observedobject.md)
- [options](xctest/xctkeypathexpectation/options.md)
- [expectedValue](xctest/xctkeypathexpectation/expectedvalue.md)

## Relationships

### Inherits From

- [XCTestExpectation](xctest/xctestexpectation.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Related Documentation

- [Using Key-Value Observing in Swift](swift/using-key-value-observing-in-swift.md)

### Key Value Observing Expectations

- [XCTKVOExpectation](xctest/xctkvoexpectation.md)
