<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTDarwinNotificationExpectation",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTDarwinNotificationExpectation"
  },
  "title" : "XCTDarwinNotificationExpectation"
}
-->

# XCTDarwinNotificationExpectation

An expectation that is fulfilled when an expected Darwin notification is received.

```
class XCTDarwinNotificationExpectation
```

## Overview

If a custom [`handler`](/documentation/XCTest/XCTDarwinNotificationExpectation/handler-swift.property) value is not provided, the expectation will be fulfilled as soon as a matching Darwin notification is received from any process.

## Topics

### Creating Darwin Notification Expectations

[`-  initWithNotificationName:`](/documentation/XCTest/XCTDarwinNotificationExpectation/init(notificationName:))

Creates an expectation that waits for a Darwin notification with the specified name to be posted.

### Expectation Properties

[`notificationName`](/documentation/XCTest/XCTDarwinNotificationExpectation/notificationName)

The name of the notification that the expectation is waiting for.

### Custom Notification Evaluation

[`handler`](/documentation/XCTest/XCTDarwinNotificationExpectation/handler-swift.property)

An optional handler that performs custom evaluation of matching notifications.

[`Handler`](/documentation/XCTest/XCTDarwinNotificationExpectation/Handler-swift.typealias)

A custom handler to be called when a matching notification is received.

## Relationships

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`Hashable`](/documentation/Swift/Hashable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Equatable`](/documentation/Swift/Equatable)

### Inherits From

[`XCTestExpectation`](/documentation/XCTest/XCTestExpectation)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)