---
title: "expectation(that:on:options:willSatisfy:)"
framework: xctest
role: symbol
role_heading: Instance Method
path: "xctest/xctestcase/expectation(that:on:options:willsatisfy:)-6itb"
---

# expectation(that:on:options:willSatisfy:)

Creates an expectation using key-value observing the test fulfills when the value of an observed property changes and satisfies the conditions of a predicate’s evaluation.

## Declaration

```swift
func expectation<T, V>(that keyPath: KeyPath<T, V>, on observedObject: T, options: NSKeyValueObservingOptions = [.initial, .new, .old], willSatisfy predicate: XCTKeyPathExpectation<T, V>.Predicate? = nil) -> XCTKeyPathExpectation<T, V> where T : NSObject
```

## Parameters

- `keyPath`: The key path for the observed property, relative to the observed object.
- `observedObject`: The object to observe the property on.
- `options`: A combination of values that specify what to include in observation notifications. For possible values, see doc://com.apple.documentation/documentation/Foundation/NSKeyValueObservingOptions.
- `predicate`: A closure that evaluates the observed object. If nil, the first observed change fulfills the expectation.

## Return Value

Return Value Creates and returns an expectation for the test case.

## See Also

### Creating Asynchronous Test Expectations

- [expectation(description:)](xctest/xctestcase/expectation(description:).md)
- [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:)-292oj.md)
- [expectation(that:on:options:willSatisfy:)](xctest/xctestcase/expectation(that:on:options:willsatisfy:)-85or0.md)
