pub unsafe trait XCTestObservation: NSObjectProtocol {
// Provided methods
fn testBundleWillStart(&self, test_bundle: &NSBundle)
where Self: Sized + Message { ... }
fn testBundleDidFinish(&self, test_bundle: &NSBundle)
where Self: Sized + Message { ... }
fn testSuiteWillStart(&self, test_suite: &XCTestSuite)
where Self: Sized + Message { ... }
fn testSuite_didRecordIssue(
&self,
test_suite: &XCTestSuite,
issue: &XCTIssue,
)
where Self: Sized + Message { ... }
fn testSuite_didRecordExpectedFailure(
&self,
test_suite: &XCTestSuite,
expected_failure: &XCTExpectedFailure,
)
where Self: Sized + Message { ... }
fn testSuiteDidFinish(&self, test_suite: &XCTestSuite)
where Self: Sized + Message { ... }
fn testCaseWillStart(&self, test_case: &XCTestCase)
where Self: Sized + Message { ... }
fn testCase_didRecordIssue(&self, test_case: &XCTestCase, issue: &XCTIssue)
where Self: Sized + Message { ... }
fn testCase_didRecordExpectedFailure(
&self,
test_case: &XCTestCase,
expected_failure: &XCTExpectedFailure,
)
where Self: Sized + Message { ... }
fn testCaseDidFinish(&self, test_case: &XCTestCase)
where Self: Sized + Message { ... }
fn testSuite_didFailWithDescription_inFile_atLine(
&self,
test_suite: &XCTestSuite,
description: &NSString,
file_path: Option<&NSString>,
line_number: NSUInteger,
)
where Self: Sized + Message { ... }
fn testCase_didFailWithDescription_inFile_atLine(
&self,
test_case: &XCTestCase,
description: &NSString,
file_path: Option<&NSString>,
line_number: NSUInteger,
)
where Self: Sized + Message { ... }
}Expand description
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:didRecordIssue: // zero or more times per test case, any time between test case start and finish -testCaseDidFinish: // exactly once per test case -testSuite:didRecordIssue: // 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
See also Apple’s documentation
Provided Methods§
Sourcefn testBundleWillStart(&self, test_bundle: &NSBundle)
fn testBundleWillStart(&self, test_bundle: &NSBundle)
Sent immediately before tests begin as a hook for any pre-testing setup.
Parameter testBundle: The bundle containing the tests that were executed.
Sourcefn testBundleDidFinish(&self, test_bundle: &NSBundle)
fn testBundleDidFinish(&self, test_bundle: &NSBundle)
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.
Parameter testBundle: The bundle containing the tests that were executed.
Sourcefn testSuiteWillStart(&self, test_suite: &XCTestSuite)
fn testSuiteWillStart(&self, test_suite: &XCTestSuite)
Sent when a test suite starts executing.
Parameter testSuite: The test suite that started. Additional information can be retrieved from the associated XCTestRun.
Sourcefn testSuite_didRecordIssue(&self, test_suite: &XCTestSuite, issue: &XCTIssue)
fn testSuite_didRecordIssue(&self, test_suite: &XCTestSuite, issue: &XCTIssue)
Sent when a test suite reports an issue. Suite issues are most commonly reported during suite-level setup and teardown whereas issues during tests are reported for the test case alone and are not reported as suite issues.
Parameter testSuite: The test suite that recorded the issue.
Parameter issue: Object with all details related to the issue.
Sourcefn testSuite_didRecordExpectedFailure(
&self,
test_suite: &XCTestSuite,
expected_failure: &XCTExpectedFailure,
)
fn testSuite_didRecordExpectedFailure( &self, test_suite: &XCTestSuite, expected_failure: &XCTExpectedFailure, )
Sent when a test suite records an expected failure.
Parameter testSuite: The test suite that recorded the expected failure.
Parameter expectedFailure: Object with all details related to the expected failure, including the suppressed issue.
Sourcefn testSuiteDidFinish(&self, test_suite: &XCTestSuite)
fn testSuiteDidFinish(&self, test_suite: &XCTestSuite)
Sent when a test suite finishes executing.
Parameter testSuite: The test suite that finished. Additional information can be retrieved from the associated XCTestRun.
Sourcefn testCaseWillStart(&self, test_case: &XCTestCase)
fn testCaseWillStart(&self, test_case: &XCTestCase)
Sent when a test case starts executing.
Parameter testCase: The test case that started. Additional information can be retrieved from the associated XCTestRun.
Sourcefn testCase_didRecordIssue(&self, test_case: &XCTestCase, issue: &XCTIssue)
fn testCase_didRecordIssue(&self, test_case: &XCTestCase, issue: &XCTIssue)
Sent when a test case reports an issue.
Parameter testCase: The test case that recorded the issue.
Parameter issue: Object with all details related to the issue.
Sourcefn testCase_didRecordExpectedFailure(
&self,
test_case: &XCTestCase,
expected_failure: &XCTExpectedFailure,
)
fn testCase_didRecordExpectedFailure( &self, test_case: &XCTestCase, expected_failure: &XCTExpectedFailure, )
Sent when a test case records an expected failure.
Parameter testCase: The test case that recorded the expected failure.
Parameter expectedFailure: Object with all details related to the expected failure, including the suppressed issue.
Sourcefn testCaseDidFinish(&self, test_case: &XCTestCase)
fn testCaseDidFinish(&self, test_case: &XCTestCase)
Sent when a test case finishes executing.
Parameter testCase: The test case that finished. Additional information can be retrieved from the associated XCTestRun.
Sourcefn testSuite_didFailWithDescription_inFile_atLine(
&self,
test_suite: &XCTestSuite,
description: &NSString,
file_path: Option<&NSString>,
line_number: NSUInteger,
)
👎Deprecated
fn testSuite_didFailWithDescription_inFile_atLine( &self, test_suite: &XCTestSuite, description: &NSString, file_path: Option<&NSString>, line_number: NSUInteger, )
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.
This method is deprecated and replaced by the -testSuite:didRecordIssue: method whose XCTIssue parameter provides greater flexibility
for describing issues that arise during testing. If the receiver of this method also responds to -testSuite:didRecordIssue:, that method
is called instead and this will not be called.
Parameter testSuite: The test suite that failed. Additional information can be retrieved from the associated XCTestRun.
Parameter description: A textual description of the failure. When replacing usage of this deprecated API, this can
be obtained using the compactDescription property on XCTIssue.
Parameter filePath: The path of file where the failure occurred or nil if unknown. When replacing usage of this deprecated API, this
can be obtained using the XCTSourceCodeLocation instance associated with an XCTIssue via its sourceCodeContext property
Parameter lineNumber: The line where the failure was reported or 0 if unknown. When replacing usage of this deprecated API, this
can be obtained using the XCTSourceCodeLocation instance associated with an XCTIssue via its sourceCodeContext property
Sourcefn testCase_didFailWithDescription_inFile_atLine(
&self,
test_case: &XCTestCase,
description: &NSString,
file_path: Option<&NSString>,
line_number: NSUInteger,
)
👎Deprecated
fn testCase_didFailWithDescription_inFile_atLine( &self, test_case: &XCTestCase, description: &NSString, file_path: Option<&NSString>, line_number: NSUInteger, )
Sent when a test case reports a failure.
This method is deprecated and replaced by the -testCase:didRecordIssue: method whose XCTIssue parameter provides greater flexibility
for describing issues that arise during testing. If the receiver of this method also responds to -testCase:didRecordIssue:, that method
is called instead and this will not be called.
Parameter testCase: The test case that failed. Additional information can be retrieved from the associated XCTestRun.
Parameter description: A textual description of the failure. When replacing usage of this deprecated API, this can
be obtained using the compactDescription property on XCTIssue.
Parameter filePath: The path of file where the failure occurred or nil if unknown. When replacing usage of this deprecated API, this
can be obtained using the XCTSourceCodeLocation instance associated with an XCTIssue via its sourceCodeContext property
Parameter lineNumber: The line where the failure was reported or 0 if unknown. When replacing usage of this deprecated API, this
can be obtained using the XCTSourceCodeLocation instance associated with an XCTIssue via its sourceCodeContext property