Contents

expectation(that:on:options:willSatisfy:)

Creates an expectation using key-value observing to monitor changes to a given key path on a given object.

Declaration

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

Parameters

  • keyPath:

    The key path to observe.

  • observedObject:

    The object to observe the key path on.

  • options:

    Options to pass to Foundation when observing changes.

  • filter:

    A syncronous predicate function you use to test observed changes to a key path. If nil, the first observed change fulfills the expectation.

Return Value

Creates and returns an expectation associated with the test case that a specific key-value observing (KVO) condition fulfills, see Using Key-Value Observing in Swift.

See Also

Creating Asynchronous Test Expectations