expectation(forNotification:object:notificationCenter:handler:)
Creates an expectation that the test fulfills when it receives a specific notification from a specific notification center for a specified object.
Declaration
func expectation(forNotification notificationName: NSNotification.Name, object objectToObserve: Any?, notificationCenter: NotificationCenter, handler: XCTNSNotificationExpectation.Handler? = nil) -> XCTestExpectationParameters
- notificationName:
The notification to register for.
- objectToObserve:
The object to observe.
- notificationCenter:
The notification center sending the notification.
- handler:
An optional Handler Swift.typealias block. If no handler is provided, the first notification matching the specified name from the observed object fulfills the expectation.
See Also
Creating Asynchronous Test Expectations
expectation(description:)expectation(for:evaluatedWith:handler:)expectation(forNotification:object:handler:)keyValueObservingExpectation(for:keyPath:expectedValue:)expectation(that:on:options:willEqual:)keyValueObservingExpectation(for:keyPath:handler:)expectation(that:on:options:willSatisfy:)expectation(that:on:options:willSatisfy:)expectation(that:on:options:willSatisfy:)