Contents

expectation(forNotification:object:handler:)

Creates an expectation that the test fulfills when it receives a specific notification for a specified object.

Declaration

func expectation(forNotification notificationName: NSNotification.Name, object objectToObserve: Any?, handler: XCTNSNotificationExpectation.Handler? = nil) -> XCTestExpectation

Parameters

  • notificationName:

    The notification to register for.

  • objectToObserve:

    The object to observe.

  • 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.

Discussion

See Also

Creating Asynchronous Test Expectations