xcuitest-suite
FreeNo executable scriptsNot checkedUse for any task that writes, fixes or reviews XCUITest UI tests for an iOS, iPadOS, tvOS or macOS app, even one test for a SwiftUI view, including locators…
by testland★ 18 GitHub starsAbout this skill
xcuitest-suite
Overview
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)
When to use
- An iOS app needs UI tests using Apple's native framework.
- A team prefers no external runtime (Appium, Detox) and wants Xcode-native test integration.
- The app is iOS-only and there's no need for cross-platform reuse.
If the app is React Native, see
detox-testing. For cross-platform
Appium-style coverage, see
appium-testing.
macOS desktop apps
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.
Step 1 - Add a UI test target
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."
Step 2 - Set accessibility identifiers in production code
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.
Step 3 - Query patterns
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))
Step 4 - Synthesize events
// 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()
Step 5 - Assert state
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.
Step 6 - Run
# 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. |
Step 7 - Parse .xcresult
The 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 o
Install xcuitest-suite in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the xcuitest-suite skill do?
Use for any task that writes, fixes or reviews XCUITest UI tests for an iOS, iPadOS, tvOS or macOS app, even one test for a SwiftUI view, including locators that break after localization: XCUIApplication, XCUIElement and queries, accessibility identifiers in app code, xcodebuild test with a destination, and reading the xcresult bundle, plus macOS privacy permission resets.
How do I install the xcuitest-suite skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the xcuitest-suite skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic