---
title: XCTNSNotificationExpectation
framework: xctest
role: symbol
role_heading: Class
path: xctest/xctnsnotificationexpectation
---

# XCTNSNotificationExpectation

An expectation that is fulfilled when an expected NSNotification is received.

## Declaration

```swift
class XCTNSNotificationExpectation
```

## Topics

### Creating NSNotification Expectations

- [init(name:)](xctest/xctnsnotificationexpectation/init(name:).md)
- [init(name:object:)](xctest/xctnsnotificationexpectation/init(name:object:).md)
- [init(name:object:notificationCenter:)](xctest/xctnsnotificationexpectation/init(name:object:notificationcenter:).md)

### Expectation Properties

- [notificationName](xctest/xctnsnotificationexpectation/notificationname.md)
- [observedObject](xctest/xctnsnotificationexpectation/observedobject.md)
- [notificationCenter](xctest/xctnsnotificationexpectation/notificationcenter.md)

### Custom Notification Evaluation

- [handler](xctest/xctnsnotificationexpectation/handler-swift.property.md)
- [XCTNSNotificationExpectation.Handler](xctest/xctnsnotificationexpectation/handler-swift.typealias.md)

## Relationships

### Inherits From

- [XCTestExpectation](xctest/xctestexpectation.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Notification-Based Expectations

- [XCTDarwinNotificationExpectation](xctest/xctdarwinnotificationexpectation.md)
