xcuitest
Skill5 starsChanged 6 months agoMITView on GitHub
When the user wants to design, implement, debug, or stabilize XCUITest tests for native iOS UI automation. Use when the user mentions "XCUITest," "XCTest," "XCUIApplication," "XCUIElement," "XCUIElementQuery," "accessibilityIdentifier," "Xcode UI test target," "xcodebuild test," "xcrun simctl," "test plans (Xcode)," or "Xcode Cloud." For cross-platform mobile see appium. For Android-native see espresso. For React Native see detox. For YAML-driven mobile see maestro.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- Prisma-Labs-Dev/apple-skillstheir own version, first seen Apr 14, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- Prisma-Labs-Dev/apple-skills★ 337same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository58 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- qa-engineering-suiteSkill
- accessibility-testingSkill
- ai-augmented-testingSkill
- appiumSkill
- artillerySkill
- bdd-anti-patternsSkill
- behaveSkill
- chaos-engineeringSkill
- ci-test-orchestrationSkill
- cloud-test-gridsSkill
- code-coverageSkill
- cucumber-gherkinSkill
- cypressSkill
- detoxSkill
- espressoSkill
- feature-flag-testingSkill
- flaky-test-managementSkill
- gatlingSkill
- go-testSkill
- graphql-testingSkill
- grpc-testingSkill
- jest-vitestSkill
- jmeterSkill
- junit-testngSkill
- k6Skill
- karateSkill
- llm-eval-testingSkill
- locustSkill
- maestroSkill
- mutation-testingSkill
- pact-contract-testingSkill
- playwrightSkill
- postman-newmanSkill
- production-testingSkill
- puppeteerSkill
- pytest-apiSkill
- pytestSkill
- qa-contextSkill
- rest-assuredSkill
- rspecSkill
- security-testingSkill
- selenium-gridSkill
- seleniumSkill
- specflow-reqnrollSkill
- supertestSkill
- testcafeSkill
- testcontainersSkill
- test-data-managementSkill
- test-design-techniquesSkill
- test-environment-managementSkill
- test-reportingSkill
- test-strategySkill
- visual-regressionSkill
- webdriverioSkill
- wiremockSkill
- xunit-nunitSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Check .agents/qa-context.md (fallback: .claude/qa-context.md) before answering.
- Distinctive: line 22
If the file does not exist, ask: deployment target / minimum iOS version, UIKit / SwiftUI / mixed, simulator-only or real-device, CI host.
- Distinctive: line 33
When *not* to use XCUITest:
- Very specific: line 84
Use accessibilityIdentifier (set in the app code) for stable element selection — *not* accessibilityLabel, which is user-visible text that …
- Very specific: line 120
Avoid sleep(N) — same anti-pattern as Selenium/Appium.
- Distinctive: line 153
Test plans are the standard way to run the same suite across locales / environments in CI.
- Very specific: line 168
Verify flags against xcodebuild -h for your installed Xcode.
- Distinctive: line 199
Use simulators for the bulk.
- Distinctive: line 219
When helping with XCUITest, ask:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
XCUITest (iOS)
You are an expert in XCUITest — Apple's native UI testing framework, built on XCTest. Your goal is to help engineers write fast, reliable iOS UI tests, design accessible apps that test well, and run XCUITest at scale. Don't fabricate XCTest assertion names, XCUIApplication methods, or xcodebuild/simctl flags. When uncertain, point the reader to Apple's developer documentation.
Initial Assessment
Check .agents/qa-context.md (fallback: .claude/qa-context.md) before answering. Pay attention to:
- iOS only? — XCUITest is iOS/iPadOS-specific. For cross-platform, mention Appium (which uses the XCUITest driver under the hood on iOS).
- Language — Swift is standard; Objective-C is supported but rare for new tests.
- App architecture — UIKit vs SwiftUI affects accessibility traits and element identification.
- Build system — Xcode project / SPM / Tuist / xcconfig matrix.
- CI host — macOS-only. Xcode Cloud, GitHub Actions macOS runner, Bitrise, CircleCI Mac, BrowserStack / Sauce / AWS Device Farm.
If the file does not exist, ask: deployment target / minimum iOS version, UIKit / SwiftUI / mixed, simulator-only or real-device, CI host.
Why XCUITest
- Native to Apple's toolchain — integrates with Xcode, runs on real devices and simulators, included in the iOS developer kit.
- Black-box but fast — runs out-of-process from the app, but Apple's instrumentation is well-tuned.
- Accessibility-driven — the same identifiers that make the app accessible make tests stable.
- Built into Xcode — record interactions, view element trees, snapshot tests in Xcode's Test Navigator.
When not to use XCUITest:
- Cross-platform team → Appium.
- React Native team → Detox.
- Headless / non-Mac CI → impossible; XCUITest requires macOS.
- Simple repetitive flows where YAML is more practical → Maestro.
Project setup
A UI test target sits alongside the app target in Xcode:
MyApp.xcodeproj
├── MyApp (app target)
├── MyAppTests (unit tests — XCTest)
└── MyAppUITests (UI tests — XCTest + XCUITest)The UI test target depends on the app's release/debug build. Tests run against a launched instance of the app via XCUIApplication.
A new UI test class typically looks like:
import XCTest
final class LoginUITests: XCTestCase {
let app = XCUIApplication()
override func setUpWithError() throws {
continueAfterFailure = false
app.launchArguments = ["-uiTesting", "1"]
app.launchEnvironment = ["MOCK_API": "true"]
app.launch()
}
func test_sign_in_with_valid_credentials() {
app.textFields["login.email"].tap()
app.textFields["login.email"].typeText("qa.user@example.com")
app.secureTextFields["login.password"].tap()
app.secureTextFields["login.password"].typeText("Pa$$w0rd-fake")
app.buttons["login.submit"].tap()
XCTAssertTrue(app.staticTexts["dashboard.welcome"].waitForExistence(timeout: 5))
}
}Use accessibilityIdentifier (set in the app code) for stable element selection — not accessibilityLabel, which is user-visible text that may localize.
Element queries
XCUIElementQuery exposes elements by type and predicates:
| Query | Example |
app.buttons["id"] | Button with accessibility id "id". |
app.textFields["..."] | Text field. |
app.cells.element(boundBy: 2) | Third cell. |
app.cells.containing(.staticText, identifier: "Widget").element | Cell containing a specific element. |
app.descendants(matching: .button).matching(NSPredicate(format: "label CONTAINS 'Sign'")) | Predicate-based. |
XCUIElement lazy-evaluates — the query runs when you access .exists / .label / .tap().
Waiting
XCUITest doesn't auto-wait the way Espresso does. Use waitForExistence(timeout:):
XCTAssertTrue(app.staticTexts["dashboard.welcome"].waitForExistence(timeout: 5))For more flexible polling, use XCTNSPredicateExpectation:
let pred = NSPredicate(format: "exists == true")
let exp = expectation(for: pred, evaluatedWith: app.staticTexts["loaded"])
wait(for: [exp], timeout: 5)Avoid sleep(N) — same anti-pattern as Selenium/Appium.
Accessibility identifiers (the right way)
Set them in the app code:
// SwiftUI
Button("Sign in") { ... }.accessibilityIdentifier("login.submit")
// UIKit
signInButton.accessibilityIdentifier = "login.submit"Identifiers are for tests; labels are for users. Tests should use identifiers; assertions on visible text can be done via label, but be aware of localization.
For SwiftUI specifically, the identifier survives recomposition and is the most reliable hook.
Test plans
Xcode test plans (.xctestplan) let you run the same target with different configurations: locale, language, environment variables, code coverage, parallelism.
SmokeTests.xctestplan
- environment: STAGING_URL=...
- locale: en_US, de_DE, ja_JP
- parallelizable: trueTest plans are the standard way to run the same suite across locales / environments in CI.
Running
| Command | Purpose |
xcodebuild test -project MyApp.xcodeproj -scheme MyAppUITests -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.0' | Run UI tests. |
xcodebuild test -workspace MyApp.xcworkspace -scheme MyApp -testPlan SmokeTests | Run via test plan. |
xcrun simctl list devices | List simulators. |
xcrun simctl boot <udid> | Boot a simulator. |
xcrun simctl push <udid> com.example.MyApp payload.json | Push notification (works on modern simulators). |
xcodebuild -resultBundlePath result.xcresult | Save the result bundle for analysis. |
Verify flags against xcodebuild -h for your installed Xcode.
Result bundles and reporting
Xcode produces an .xcresult bundle on every run. Open in Xcode to see per-test status, screenshots, attachments. For CI:
xcresulttoolextracts JSON / HTML summaries.xchtmlreport(community tool) generates a friendlier HTML report.- For CI integration, JUnit XML is producible from xcresult via tooling — verify which one your CI consumes.
Snapshot / record mode
Xcode's Test Navigator has a record button that captures interactions as code. Useful for bootstrapping locators — always review the generated code. Recordings tend to be brittle (literal index-based queries) and need to be rewritten to use accessibility identifiers.
Real device vs simulator
| Concern | Simulator | Real device |
| Most UI tests | ✅ | ✅ |
| Push notifications | ✅ (modern Xcode + simctl push) | ✅ |
| Apple Pay | ⚠ Mock only | ✅ |
| Biometric auth | ✅ via XCUIDevice.shared.perform(...) and Hardware menu (manual) | ✅ |
| Camera / mic / sensors | Limited | ✅ |
| Performance numbers | Misleading | Accurate |
Use simulators for the bulk; real devices for capabilities that simulators can't realistically replicate.
Common Pitfalls
- Using
accessibilityLabelfor locators — labels are user-visible and localized. UseaccessibilityIdentifier. - Long index-based queries from recording —
cells.element(boundBy: 4)breaks on minor list changes. Replace with identifier-based queries. sleep(5)for timing — usewaitForExistence(timeout:).- Not setting
continueAfterFailure = false— first failure cascades into ten more, drowning the report. - Forgetting
launchArguments/launchEnvironmentfor test-mode toggles — app should detect test mode and stub external services or disable animations. - One mega-test method — split by behavior. Each test should set up and verify one outcome.
- Letting localization randomness affect tests — set
app.launchArguments += ["-AppleLanguages", "(en)"]if you need a locked locale. - Running on simulator-only when business logic depends on real hardware — biometric, camera, NFC.
- Not using test plans for locale matrix — easy way to multiply coverage without copy-pasting test files.
Task-Specific Questions
When helping with XCUITest, ask:
- Minimum iOS version target?
- UIKit, SwiftUI, or mixed?
- Have accessibility identifiers been added to the testable elements?
- Are tests running locally, on Xcode Cloud, GitHub Actions macOS, Bitrise, BrowserStack, etc.?
- Are test plans in use for locale / environment matrix?
- Real-device-required scenarios (biometric, camera, push)?
- How are results captured — xcresult, xchtmlreport, JUnit XML for CI?
Related Skills
- appium — cross-platform alternative (uses XCUITest driver under the hood).
- espresso — Android-native equivalent.
- detox — React Native gray-box alternative.
- maestro — YAML-driven, simpler.
- xunit-nunit / junit-testng — different ecosystems but conceptually similar test patterns.
- ci-test-orchestration — for parallelizing on macOS runners and Xcode Cloud setups.
- cloud-test-grids — BrowserStack / Sauce / AWS Device Farm for managed iOS device pools.
- accessibility-testing — accessibility identifiers double as test hooks and accessibility features; aligned investment.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

