XCTest is the testing framework for writing and running unit, performance, and UI tests across Apple platforms. You define tests by subclassing XCTestCase, group them with XCTestSuite, and verify behavior with assertions whose failures are recorded as issues through types such as XCTIssueReference and XCTMutableIssue. To validate asynchronous code, you create an XCTestExpectation and block on it with XCTWaiter, and you measure performance using metrics like XCTClockMetric, XCTCPUMetric, and XCTMemoryMetric configured through XCTMeasureOptions. You can also observe test execution with XCTestObservation and XCTestObservationCenter, capture diagnostics as an XCTAttachment, and mark known problems with XCTExpectedFailure.
Essentials 3
The base test class and the case and suite types you subclass and group to define tests.
- ClXCTest@class XCTest
- ClXCTestCase@class XCTestCase
- ClXCTestSuite@class XCTestSuite
Test Execution and Results 3
Objects that track the run of individual tests and suites and collect their outcomes.
- ClXCTestRun@class XCTestRun
- ClXCTestCaseRunA test run that records the execution and results of a single test case.
- ClXCTestSuiteRunA test run that records the execution and aggregated results of a test suite.
Asynchronous Testing 7
Expectations and waiters for validating code that completes asynchronously.
- ClXCTestExpectation@class XCTestExpectation
- ClXCTWaiter@class XCTWaiter
- PrXCTWaiterDelegate@protocol XCTWaiterDelegate
- ClXCTKVOExpectation@class XCTKVOExpectation
- ClXCTNSNotificationExpectation@class XCTNSNotificationExpectation
- ClXCTNSPredicateExpectation@class XCTNSPredicateExpectation
- ClXCTDarwinNotificationExpectation@class XCTDarwinNotificationExpectation
Failures and Issues 5
Types that represent, mark, and inspect the issues recorded when assertions fail.
- ClXCTIssueReference@class XCTIssue
- ClXCTMutableIssue@class XCTMutableIssue
- ClXCTExpectedFailure@class XCTExpectedFailure
- StXCTestErrorA structure describing errors thrown by the XCTest framework, such as timeouts and skips.
- En_XCTAssertionTypeAn enumeration of the internal assertion kinds used to categorize recorded test failures.
Performance Measurement 11
Metrics and options for measuring and reporting the performance of code under test.
- PrXCTMetric@protocol XCTMetric
- ClXCTMeasureOptions@class XCTMeasureOptions
- ClXCTPerformanceMeasurement@class XCTPerformanceMeasurement
- ClXCTPerformanceMeasurementTimestamp@class XCTPerformanceMeasurementTimestamp
- StXCTPerformanceMetricA structure of constants identifying the built-in performance metrics XCTest can measure.
- ClXCTClockMetriciOS 13.0+@class XCTClockMetric
- ClXCTCPUMetriciOS 13.0+@class XCTCPUMetric
- ClXCTMemoryMetriciOS 13.0+@class XCTMemoryMetric
- ClXCTStorageMetriciOS 13.0+@class XCTStorageMetric
- ClXCTOSSignpostMetriciOS 13.0+@class XCTOSSignpostMetric
- ClXCTApplicationLaunchMetriciOS 13.0+@class XCTApplicationLaunchMetric
Activities and Attachments 3
APIs for grouping test steps into activities and capturing diagnostic attachments.
- ClXCTContextAn object that provides access to the runtime context for grouping work into named activities.
- PrXCTActivityRepresents a test activity.
- ClXCTAttachment@class XCTAttachment
Source Code Context 4
Types that describe the source locations, frames, and symbols associated with a test event.
- ClXCTSourceCodeLocation@class XCTSourceCodeLocation
- ClXCTSourceCodeSymbolInfo@class XCTSourceCodeSymbolInfo
- ClXCTSourceCodeFrame@class XCTSourceCodeFrame
- ClXCTSourceCodeContext@class XCTSourceCodeContext
Observing Test Runs 3
Protocols and centers for receiving callbacks as tests and suites start and finish.
- PrXCTestObservation@protocol XCTestObservation
- ClXCTestObservationCenter@class XCTestObservationCenter
- ClXCTestObserverXCTestObserver is deprecated.
Logging and Internals 4
Lower-level logging, probing, and exception types used internally by the test runtime.
- ClXCTestLogA legacy observer that writes a textual log of test execution progress.
- ClXCTestProbeAn internal type used to probe the state of the test runtime.
- Cl_XCTestCaseInterruptionExceptionAn internal exception used to interrupt a test case when execution must be aborted.
- Cl_XCTSkipFailureExceptionAn internal exception thrown to skip the remainder of a test when a skip is requested.
Type Aliases 1
- TyXCWaitCompletionHandler@typedef XCWaitCompletionHandler