Protocol

XCTestObservation

The XCTestObservation protocol defines methods that are called in response to significant events in the progress of test runs.

Declaration

protocol XCTestObservation

Overview

See XCTestObservationCenter for details on registering and removing test observers.

The notification methods for XCTestObservation are called in the following sequence for a test bundle:

  1. testBundleWillStart(_:) is called exactly once per test bundle

  2. testSuiteWillStart(_:) is called exactly once per test suite

  3. testCaseWillStart(_:) is called exactly once per test case

  4. testCase(_:didFailWithDescription:inFile:atLine:) is called zero or more times per test case, at any point between test case start and finish

  5. testCaseDidFinish(_:) is called exactly once per test case

  6. testSuite(_:didFailWithDescription:inFile:atLine:) is called zero or more times per test suite, at any point between test suite start and finish

  7. testSuiteDidFinish(_:) is called exactly once per test suite

  8. testBundleDidFinish(_:) is called exactly once per test bundle

Topics

Observation Methods

func testBundleWillStart(Bundle)

Called immediately before any tests in a test bundle begin.

func testSuiteWillStart(XCTestSuite)

Called immediately before a test suite starts executing.

func testCaseWillStart(XCTestCase)

Called immediately before a test case starts executing.

func testCaseDidFinish(XCTestCase)

Called immediately after a test case finishes executing.

func testSuiteDidFinish(XCTestSuite)

Called immediately after a test suite finishes executing.

func testBundleDidFinish(Bundle)

Called immediately after all tests in a test bundle have finished executing.

Relationships

Inherits From

See Also

Test Observation

class XCTestObservationCenter

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