XCUITest
What is XCUITest?
XCUITest is Apple's first-party UI testing framework, introduced in Xcode 7. It replaced UIAutomation (deprecated in iOS 10) and is now the only supported way to write UI tests for iOS apps submitted to the App Store. XCUITest tests run as a separate process that communicates with the app under test via the Accessibility framework, and they can be executed on both simulators and real devices. Key capabilities: element queries using identifiers, labels, and accessibility identifiers; gesture simulation (tap, swipe, pinch, rotate); screenshot capture; and performance measurement via XCTMetrics. XCUITest is the fastest iOS UI test execution option since it requires no proxy layer.
XCUITest, frequently asked questions
XCUITest is used to write automated UI tests for iOS, iPadOS, and tvOS apps. It simulates user interactions (taps, swipes, text input), verifies UI state (element existence, label text, enabled state), and can measure performance metrics. XCUITest tests run in Xcode and on CI via 'xcodebuild test'.
The most important practice is using accessibilityIdentifier on interactive elements rather than relying on displayed text or element order, which can change with copy updates or UI rearrangement. Use XCTNSPredicateExpectation for asynchronous state (network loading, animations) instead of fixed sleeps. Keep each test independent: launch fresh, use launch arguments or environment variables to set initial state.