keyValueObservingExpectation(for:keyPath:expectedValue:)
Creates an expectation that uses Key-Value Observing to observe a value until it matches an expected value.
Declaration
func keyValueObservingExpectation(for objectToObserve: Any, keyPath: String, expectedValue: Any?) -> XCTestExpectationParameters
- objectToObserve:
The object to observe.
- keyPath:
The key path to observe.
- expectedValue:
Expected value of the value specified by
keyPath. The expectation will fulfill itself when the value atkeyPathis equal toexpectedValue, as tested usingisEqual:. IfexpectedValueisnil, the expectation will be fulfilled by the first change to the key path of the observed object.
Return Value
Creates and returns an expectation associated with the test case.
Discussion
Creates an XCTestExpectation that uses Key Value Observing to observe changes on the provided object until the value specified by keyPath matches the expected value using isEqual:.
See Also
Creating Asynchronous Test Expectations
expectation(description:)expectation(for:evaluatedWith:handler:)expectation(forNotification:object:handler:)expectation(forNotification:object:notificationCenter:handler:)expectation(that:on:options:willEqual:)keyValueObservingExpectation(for:keyPath:handler:)expectation(that:on:options:willSatisfy:)expectation(that:on:options:willSatisfy:)expectation(that:on:options:willSatisfy:)