XCTestObservation Protocol Reference
Conforms to | NSObject |
---|---|
Declared in | XCTestObservation.h |
Overview
@protocol XCTestObservation
Objects conforming to XCTestObservation can register to be notified of the progress of test runs. See XCTestObservationCenter for details on registration.
Progress events are delivered in the following sequence:
testBundleWillStart: // exactly once per test bundle testSuiteWillStart: // exactly once per test suite testCaseWillStart: // exactly once per test case -testCase:didFailWithDescription:… // zero or more times per test case, any time between test case start and finish testCaseDidFinish: // exactly once per test case -testSuite:didFailWithDescription:… // zero or more times per test suite, any time between test suite start and finish testSuiteDidFinish: // exactly once per test suite testBundleDidFinish: // exactly once per test bundle
– testBundleWillStart:
@method -testBundleWillStart:
- (void)testBundleWillStart:(NSBundle *)testBundle
Parameters
testBundle |
The bundle containing the tests that were executed. |
---|
Discussion
Sent immediately before tests begin as a hook for any pre-testing setup.
Declared In
XCTestObservation.h
– testBundleDidFinish:
@method -testBundleDidFinish:
- (void)testBundleDidFinish:(NSBundle *)testBundle
Parameters
testBundle |
The bundle containing the tests that were executed. |
---|
Discussion
Sent immediately after all tests have finished as a hook for any post-testing activity. The test process will generally exit after this method returns, so if there is long running and/or asynchronous work to be done after testing, be sure to implement this method in a way that it blocks until all such activity is complete.
Declared In
XCTestObservation.h
– testSuiteWillStart:
@method -testSuiteWillStart:
- (void)testSuiteWillStart:(XCTestSuite *)testSuite
Parameters
testSuite |
The test suite that started. Additional information can be retrieved from the associated XCTestRun. |
---|
Discussion
Sent when a test suite starts executing.
Declared In
XCTestObservation.h
– testSuite:didFailWithDescription:inFile:atLine:
@method -testSuiteDidFail:withDescription:inFile:atLine:
- (void)testSuite:(XCTestSuite *)testSuite didFailWithDescription:(NSString *)description inFile:(nullable NSString *)filePath atLine:(NSUInteger)lineNumber
Parameters
testSuite |
The test suite that failed. Additional information can be retrieved from the associated XCTestRun. |
---|---|
description |
A textual description of the failure. |
filePath |
The path of file where the failure occurred, nil if unknown. |
lineNumber |
The line where the failure was reported. |
Discussion
Sent when a test suite reports a failure. Suite failures are most commonly reported during suite-level setup and teardown whereas failures during tests are reported for the test case alone and are not reported as suite failures.
Declared In
XCTestObservation.h
– testSuiteDidFinish:
@method -testSuiteDidFinish:
- (void)testSuiteDidFinish:(XCTestSuite *)testSuite
Parameters
testSuite |
The test suite that finished. Additional information can be retrieved from the associated XCTestRun. |
---|
Discussion
Sent when a test suite finishes executing.
Declared In
XCTestObservation.h
– testCaseWillStart:
@method -testCaseWillStart:
- (void)testCaseWillStart:(XCTestCase *)testCase
Parameters
testCase |
The test case that started. Additional information can be retrieved from the associated XCTestRun. |
---|
Discussion
Sent when a test case starts executing.
Declared In
XCTestObservation.h
– testCase:didFailWithDescription:inFile:atLine:
@method -testCaseDidFail:withDescription:inFile:atLine:
- (void)testCase:(XCTestCase *)testCase didFailWithDescription:(NSString *)description inFile:(nullable NSString *)filePath atLine:(NSUInteger)lineNumber
Parameters
testCase |
The test case that failed. Additional information can be retrieved from the associated XCTestRun. |
---|---|
description |
A textual description of the failure. |
filePath |
The path of file where the failure occurred, nil if unknown. |
lineNumber |
The line where the failure was reported. |
Discussion
Sent when a test case reports a failure.
Declared In
XCTestObservation.h
– testCaseDidFinish:
@method -testCaseDidFinish:
- (void)testCaseDidFinish:(XCTestCase *)testCase
Parameters
testCase |
The test case that finished. Additional information can be retrieved from the associated XCTestRun. |
---|
Discussion
Sent when a test case finishes executing.
Declared In
XCTestObservation.h