CheckOps
XCTest
XCTest is Apple's testing framework for unit, performance and UI tests in Xcode projects across Apple platforms, with assertions, expectations for async code, performance metrics and code coverage.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
XCTest is Apple’s framework for creating and running unit tests, performance tests and UI tests for Xcode projects. It is built into Xcode, works with Swift and Objective-C, and supports iOS, iPadOS, macOS, tvOS, watchOS and visionOS. An open-source implementation, swift-corelibs-xctest, provides XCTest on Linux and other platforms.
Tests are methods starting with test in subclasses of XCTestCase, using assertions such as XCTAssertEqual, XCTAssertTrue, XCTAssertNil and XCTAssertThrowsError, plus XCTUnwrap for optionals. Setup and teardown run per test or per class, and async throws tests work with Swift concurrency, while XCTestExpectation and fulfillment(of:) handle callback-based asynchrony. Performance tests use measure(metrics:) with clock, CPU, memory and storage metrics and baselines. UI tests drive apps with XCUIApplication (see XCUITest). Xcode test plans configure test configurations, parallel testing, repetition for flaky tests and code coverage, and xcodebuild test runs suites in CI.
Results are stored in .xcresult bundles that Xcode and command-line tools can inspect, including logs, attachments and screenshots captured with XCTAttachment, which helps diagnose failures from CI runs. XCTest can also run alongside Swift Testing in the same target, so existing suites do not need to be rewritten.
Features
- Built into Xcode: No dependencies; works across Apple platforms.
- Async support: async tests and expectations.
- Performance tests: Metrics and baselines with
measure. - Test plans and coverage: Configurations, parallelism, retries and coverage.
Pros
- Free: Included with Xcode.
- First-party: Apple-supported across all its platforms.
Cons
- Verbose assertions: Swift Testing’s
#expectis more expressive. - Apple-centric: Best experience requires Xcode on macOS.
Usage and Links (Example)
import XCTest
@testable import Shop
final class OrderServiceTests: XCTestCase {
var service: OrderService!
override func setUp() {
service = OrderService(api: FakeAPI())
}
func testPlacesOrder() async throws {
let order = try await service.place(items: [.apple])
XCTAssertEqual(order.status, .confirmed)
}
func testPerformance() {
measure { _ = service.priceAll(Array(repeating: .apple, count: 10_000)) }
}
}
xcodebuild test -scheme Shop -destination 'platform=iOS Simulator,name=iPhone 16'
Resources:
Pricing
Free with Xcode.
Recommended for?
- All Apple-platform developers, especially for UI and performance tests.
- Existing suites that predate Swift Testing.
Conclusion
XCTest is the foundation of testing on Apple platforms; new unit tests may use Swift Testing, but XCTest remains essential for UI and performance testing.
Alternatives
Other tools on CheckOps that cover similar ground. Open a page, or compare one with XCTest side by side.
SSwift TestingSwift Testing is Apple's open-source (Apache-2.0) testing library for Swift, using @Test and #expect macros, parameterised tests, traits and parallel execution, included in Xcode 16 and Swift 6 toolchains.Compare with XCTest
NNimbleNimble is an Apache-2.0 matcher framework for Swift and Objective-C, offering expressive expect(...).to(...) assertions and asynchronous toEventually expectations, used with XCTest or Quick.Compare with XCTest
SSnapshotTesting (Point-Free)SnapshotTesting is Point-Free's MIT-licensed snapshot testing library for Swift, snapshotting views, view controllers and any value as images, text, JSON and more, with XCTest and Swift Testing support.Compare with XCTest
XXCUITestA test automation framework for iOS applications, part of the XCTest framework.Compare with XCTest
VViewInspectorViewInspector is an MIT-licensed library for unit testing SwiftUI views at runtime, letting tests traverse the view hierarchy, read values and trigger actions such as button taps.Compare with XCTest
AAppiumCross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol.Compare with XCTest