<!--
{
  "availability" : [

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

# XCTestObservationCenter

Provides information about the progress of test runs to registered observers.

```
class XCTestObservationCenter
```

## Overview

Observers can be any object that conforms to the [`XCTestObservation`](/documentation/XCTest/XCTestObservation) protocol. Register new observers with the [`addTestObserver(_:)`](/documentation/XCTest/XCTestObservationCenter/addTestObserver(_:)) method and remove them with the [`removeTestObserver(_:)`](/documentation/XCTest/XCTestObservationCenter/removeTestObserver(_:)) method.

If an [NSPrincipalClass](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/plist/info/NSPrincipalClass) key is declared in the test bundle’s Info.plist file, XCTest automatically creates a single instance of that class when the test bundle is loaded. You can use this instance as a place to register observers or do other pretesting global setup before testing for that bundle begins.

> Important:
> Observers must be registered manually. The NSPrincipalClass instance is not automatically registered as an observer even if the class conforms to ``doc://com.apple.xctest/documentation/XCTest/XCTestObservation``.

## Topics

### Accessing the Shared Observation Center

[`shared`](/documentation/XCTest/XCTestObservationCenter/shared)

The shared [`XCTestObservationCenter`](/documentation/XCTest/XCTestObservationCenter) singleton instance.

### Managing Observers

[`addTestObserver(_:)`](/documentation/XCTest/XCTestObservationCenter/addTestObserver(_:))

Registers an object conforming to [`XCTestObservation`](/documentation/XCTest/XCTestObservation) as an observer for the current test session.

[`removeTestObserver(_:)`](/documentation/XCTest/XCTestObservationCenter/removeTestObserver(_:))

Unregisters an object conforming to [`XCTestObservation`](/documentation/XCTest/XCTestObservation) as an observer for the current test session.



---

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)