/qa-mobile:xcuitest-suitefrom qa-mobile
Writes, fixes, and reviews XCUITest UI tests for iOS, iPadOS, tvOS, and macOS apps. Covers XCUIApplication, XCUIElement queries, accessibility identifiers, xcodebuild test destinations, xcresult bundle reading, and macOS privacy permission resets.
Ships in qa-mobile. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
XCUITest is Apple's first-party UI testing framework, integrated with Xcode and built on the XCTest framework (xcui-fundamentals).
"UI testing in Xcode is built on three fundamental classes: XCUIApplication, XCUIElement, XCUIElementQuery." (xcui-fundamentals)
The general pattern: Query → Synthesize → Assert.
"1. Query - Use XCUIElementQuery to find an XCUIElement 2. Synthesize - Synthesize an event and send it to the XCUIElement 3. Assert - Use an assertion to compare the element's state against expected reference state" (xcui-fundamentals)
If the app is React Native, see
detox-testing. For cross-platform
Appium-style coverage, see
appium-testing.
The same framework tests macOS desktop apps (AppKit, SwiftUI, Catalyst) - every
step below carries over. The macOS delta - -destination 'platform=macOS'
flags, TCC privacy-permission resets (tccutil reset), per-device performance
baselines, and headless-runner constraints - is in
references/macos.md.
In Xcode: File → New → Target → UI Testing Bundle. The template
generates a .swift test class with a default setUp:
import XCTest
final class CartUITests: XCTestCase {
override func setUpWithError() throws {
continueAfterFailure = false // critical (default)
XCUIApplication().launch()
}
}
Per xcui-fundamentals:
"
continueAfterFailure = NOis the default (recommended) because UI test steps are dependent on previous steps."
XCUITest finds elements via the accessibility tree. Hard-coded labels / text are brittle - set explicit identifiers in the SUT:
// Production code
let placeOrderButton = UIButton()
placeOrderButton.accessibilityIdentifier = "place-order-button"
Then in tests:
let app = XCUIApplication()
app.buttons["place-order-button"].tap()
accessibilityIdentifier (not accessibilityLabel) - labels are
user-facing and translated; identifiers are dev-only and stable.
let app = XCUIApplication()
// By accessibility identifier (preferred)
app.buttons["place-order-button"].tap()
app.textFields["email-field"].typeText("[email protected]")
// By type + text
app.staticTexts["Welcome"].swipeUp()
// Predicate-based query
let cells = app.tables.cells.matching(
NSPredicate(format: "label CONTAINS[c] 'BOOK-001'")
)
cells.element(boundBy: 0).tap()
// Wait for an element
XCTAssert(app.staticTexts["Order confirmed"].waitForExistence(timeout: 5))
// Tap
app.buttons["submit"].tap()
// Type
app.textFields["email"].typeText("[email protected]")
// Swipe / drag
app.cells.element(boundBy: 0).swipeLeft()
// Pinch
app.images["map"].pinch(withScale: 2.0, velocity: 1.0)
// Press for duration (long-press)
app.buttons["context-menu"].press(forDuration: 1.0)
// System keyboard return
app.keyboards.buttons["return"].tap()
let confirmation = app.staticTexts["Order confirmed"]
XCTAssertTrue(confirmation.exists)
XCTAssertEqual(app.staticTexts["order-id"].label, "ORD-12345")
XCTAssertTrue(app.buttons["submit"].isEnabled)
exists returns immediately; waitForExistence(timeout:) waits
up to N seconds. Use waitForExistence for any post-tap state
that depends on async work.
# From the project directory:
xcodebuild test \
-project MyApp.xcodeproj \
-scheme MyApp \
-destination 'platform=iOS Simulator,name=iPhone 15,OS=latest' \
-resultBundlePath TestResults.xcresult
Per-destination patterns:
| Use | Destination string |
|---|---|
| Latest sim | 'platform=iOS Simulator,name=iPhone 15,OS=latest' |
| Specific OS | 'platform=iOS Simulator,name=iPhone 14,OS=17.4' |
| Connected device | 'platform=iOS,id=<UDID>' |
| Multi-device matrix | Pass -destination multiple times. |
.xcresultThe result bundle is binary. Extract via xcresulttool:
xcrun xcresulttool get test-results summary --path TestResults.xcresult --format json > results.json
Then use junit-xml-analysis (in the qa-test-reporting plugin)
on the JUnit-equivalent shape (or directly on the JSON for richer
data).
# .github/workflows/ios-tests.yml
jobs:
ui-tests:
runs-on: macos-15
steps:
- uses: actions/checkout@v5
- run: xcodebuild test -project MyApp.xcodeproj -scheme MyApp \
-destination 'platform=iOS Simulator,name=iPhone 15,OS=latest' \
-resultBundlePath TestResults.xcresult
- uses: actions/upload-artifact@v4
if: always()
with:
name: xcresult
path: TestResults.xcresult
GitHub Actions provides macos-15 runners with Xcode pre-installed.
| Anti-pattern | Why it fails | Fix |
|---|---|---|
Querying by accessibilityLabel | Labels are translated; tests fail in non-English locales. | Use accessibilityIdentifier (Step 2-3). |
Thread.sleep for async waits | Flaky on slow runners; slow on fast. | waitForExistence(timeout:) (Step 5). |
continueAfterFailure = true | One failure cascades into N false positives. | Default false (Step 1). |
| Hard-coded text in queries | Copy changes break tests. | accessibility identifiers (Step 2). |
| Running against wrong destination ("latest" without pin) | Test passes on Xcode 16, fails on 15; reproducibility issues. | Pin OS version explicitly in CI. |
Skipping xcresult upload | Failure debugging needs the screenshots / videos in the bundle. | Always upload (Step 8). |
percy-visual-regression-testing (in the qa-visual-regression plugin)
or screenshot-comparison helpers.continueAfterFailure = NO default.espresso-suite - Android sibling.appium-testing - cross-platform
alternative when iOS + Android share tests.junit-xml-analysis - downstream parser for JUnit-converted xcresult.evals/green-checkout-suite-that-never-opened-the-app/criteria.json (opens in a new tab)evals/green-checkout-suite-that-never-opened-the-app/task.md (opens in a new tab)evals/mac-app-tests-hang-on-the-rack-mini-at-2am/criteria.json (opens in a new tab)evals/mac-app-tests-hang-on-the-rack-mini-at-2am/task.md (opens in a new tab)evals/one-bug-arrived-as-twenty-two-nightly-failures/criteria.json (opens in a new tab)evals/one-bug-arrived-as-twenty-two-nightly-failures/task.md (opens in a new tab)evals/release-report-said-zero-failures-on-a-red-run/criteria.json (opens in a new tab)evals/release-report-said-zero-failures-on-a-red-run/task.md (opens in a new tab)evals/voiceover-now-reads-out-our-internal-test-hooks/criteria.json (opens in a new tab)evals/voiceover-now-reads-out-our-internal-test-hooks/task.md (opens in a new tab)references/macos.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
8 skills in this plugin
/appium-testingUse for any question or task about Appium mobile UI tests, even a quick fix, including tests that break after an Appium upgrade and suites that pass on Android but fail on iOS: one suite for iOS and Android (native or React Native) with XCUITest, UiAutomator2 and Espresso drivers, capabilities, clients in JS, Python, Java, Ruby or .NET, simulators, emulators and device farms./detox-testingUse whenever a React Native app needs end-to-end tests with Detox: gray-box runs inside the app, by.id, by.text and by.label matchers, waitFor for extra sync, and the Jest runner. Flutter is flutter-testing; cross-platform black-box is appium-testing; YAML flows are maestro-flows./espresso-suitenpx claudepluginhub testland/qa --plugin qa-mobileOther plugins' skills for the same job