---
title: XCTKeyPathExpectation.Predicate
framework: xctest
role: symbol
role_heading: Type Alias
path: xctest/xctkeypathexpectation/predicate
---

# XCTKeyPathExpectation.Predicate

A function the key path expectation uses to test the value of an observed property.

## Declaration

```swift
typealias Predicate = @Sendable (T, NSKeyValueObservedChange<V>) async -> Bool
```

## Parameters

- `observedObject`: The observed object to evaluate with the property that changes.
- `change`: A value that describes the observed change.

## Return Value

Return Value Returns true if the change fulfills the expectation; otherwise, false.

## Discussion

Discussion A key path expectation uses this function to determine whether the value of the observed property fulfills the conditions of the expectation. The system invokes the function asyncronously on a detached task and may call the function more that once.

## See Also

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