XCTest
By Apple
XCTest is Apple's native testing framework, bundled with Xcode, for writing and running unit tests, UI tests, and performance tests for Swift and Objective-C applications.
Definition
XCTest is Apple's native testing framework, bundled with Xcode, for writing and running unit tests, UI tests, and performance tests for Swift and Objective-C applications.
Overview
XCTest ships with Xcode and is Apple's standard framework for automated testing across its platforms. Test classes subclass XCTestCase and use assertion methods like XCTAssertEqual to verify expected behavior. Its XCUITest extension drives UI tests by simulating taps, swipes, and other gestures against a running app, while performance tests measure execution time and other metrics across runs. Results integrate directly into Xcode's Test Navigator and code coverage reports. In CI pipelines, XCTest suites are commonly triggered via the command line using xcodebuild, often from GitHub Actions running on macOS build agents — filling a role similar to how Jest serves JavaScript testing or Selenium serves browser-based UI testing on the web.
Key Features
- Unit testing via XCTestCase subclasses and assertion macros
- XCUITest extension for automated UI testing through simulated gestures
- Performance testing to measure execution time and resource usage
- Deep integration with Xcode's Test Navigator and code coverage reports
- Asynchronous test support via expectations for testing async code
- Command-line execution via xcodebuild for CI/CD pipelines