---
title: XCTestObservation
framework: xctest
role: symbol
role_heading: Protocol
path: xctest/xctestobservation
---

# XCTestObservation

A protocol that defines methods the test runner calls in response to significant events during test runs.

## Declaration

```swift
protocol XCTestObservation : NSObjectProtocol
```

## Overview

Overview The system calls the notification methods for XCTestObservation in the following sequence for a test bundle: testBundleWillStart(_:) — exactly once per test bundle testSuiteWillStart(_:) — exactly once per test suite testCaseWillStart(_:) — exactly once per test case testCase(_:didRecord:)  — for each test failure, zero or more times per test case at any point between test case start and finish testCase(_:didRecord:)  — for each expected test failure, zero or more times per test case at any point between test case start and finish testCaseDidFinish(_:) — exactly once per test case testSuite(_:didRecord:) — for each test failure, zero or more times per test suite at any point between test suite start and finish testSuite(_:didRecord:) — for each expected test failure, zero or more times per test suite at any point between test suite start and finish testSuiteDidFinish(_:) — exactly once per test suite testBundleDidFinish(_:) — exactly once per test bundle See XCTestObservationCenter for details about registering and removing test observers.

## Topics

### Observation Methods

- [testBundleWillStart(_:)](xctest/xctestobservation/testbundlewillstart(_:).md)
- [testSuiteWillStart(_:)](xctest/xctestobservation/testsuitewillstart(_:).md)
- [testCaseWillStart(_:)](xctest/xctestobservation/testcasewillstart(_:).md)
- [testCase(_:didRecord:)](xctest/xctestobservation/testcase(_:didrecord:)-4cou6.md)
- [testCase(_:didRecord:)](xctest/xctestobservation/testcase(_:didrecord:)-8k955.md)
- [testCase(_:didFailWithDescription:inFile:atLine:)](xctest/xctestobservation/testcase(_:didfailwithdescription:infile:atline:).md)
- [testCaseDidFinish(_:)](xctest/xctestobservation/testcasedidfinish(_:).md)
- [testSuite(_:didRecord:)](xctest/xctestobservation/testsuite(_:didrecord:)-3rk9k.md)
- [testSuite(_:didRecord:)](xctest/xctestobservation/testsuite(_:didrecord:)-1xjkv.md)
- [testSuite(_:didFailWithDescription:inFile:atLine:)](xctest/xctestobservation/testsuite(_:didfailwithdescription:infile:atline:).md)
- [testSuiteDidFinish(_:)](xctest/xctestobservation/testsuitedidfinish(_:).md)
- [testBundleDidFinish(_:)](xctest/xctestobservation/testbundledidfinish(_:).md)

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Test Observation

- [XCTestObservationCenter](xctest/xctestobservationcenter.md)
