跳到正文
cccskills
免费在 GitHub 公开

xcuitest-suite

Authors XCUIest UI tests for iOS / iPadOS / tvOS and macOS desktop apps - uses the three-class XCUIApplication / XCUIElement / XCUIElementQuery pattern, sets accessibility identifiers on production code, runs via `xcodebuild test` with destination, parses the `xcresult` bundle. The macOS desktop delta (platform=macOS destination flags, TCC privacy-permission resets, per-device performance baselines) is in references/macos.md. Use when an iOS or macOS app needs UI tests in Apple's first-party framework (no external runtime; native to Xcode).

中文简介正在准备中。当前显示原文说明。

testland/qa星标 13(GitHub 13 + cccskills 0)

实测评分 未实测

查看安装方法

包含的文件(13)

  • SKILL.md8.5 KB
  • .tessl-plugin/plugin.json676 B
  • evals/green-checkout-suite-that-never-opened-the-app/criteria.json7.2 KB
  • evals/green-checkout-suite-that-never-opened-the-app/task.md10.8 KB
  • evals/mac-app-tests-hang-on-the-rack-mini-at-2am/criteria.json7.8 KB
  • evals/mac-app-tests-hang-on-the-rack-mini-at-2am/task.md11.0 KB
  • evals/one-bug-arrived-as-twenty-two-nightly-failures/criteria.json6.9 KB
  • evals/one-bug-arrived-as-twenty-two-nightly-failures/task.md13.4 KB
  • evals/release-report-said-zero-failures-on-a-red-run/criteria.json7.3 KB
  • evals/release-report-said-zero-failures-on-a-red-run/task.md10.5 KB
  • evals/voiceover-now-reads-out-our-internal-test-hooks/criteria.json6.6 KB
  • evals/voiceover-now-reads-out-our-internal-test-hooks/task.md12.3 KB
  • references/macos.md4.1 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

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 = NO is 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("user@example.com")

// 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("user@example.com")

// 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:

UseDestination 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 matrixPass -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 on the JSON for richer data).

Step 8 - CI integration

# .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-patterns

Anti-patternWhy it failsFix
Querying by accessibilityLabelLabels are translated; tests fail in non-English locales.Use accessibilityIdentifier (Step 2-3).
Thread.sleep for async waitsFlaky on slow runners; slow on fast.waitForExistence(timeout:) (Step 5).
continueAfterFailure = trueOne failure cascades into N false positives.Default false (Step 1).
Hard-coded text in queriesCopy 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 uploadFailure debugging needs the screenshots / videos in the bundle.Always upload (Step 8).

Limitations

  • macOS only. Xcode + Simulator require macOS hosts.
  • Slower than unit tests. Each test launches the app; expect 10-30s per test. Keep UI test count modest.
  • Flaky on Simulator under load. CI runners under contention produce intermittent failures; use retries cautiously (don't mask real bugs).
  • No first-party visual regression. Pair with percy-visual-regression-testing (in the qa-visual-regression plugin) or screenshot-comparison helpers.

References

  • xcui - Apple's XCUITest fundamentals: three-class pattern (XCUIApplication / XCUIElement / XCUIElementQuery), Query→Synthesize→Assert, continueAfterFailure = NO default.
  • references/macos.md - the macOS desktop delta (destination flags, TCC permissions, CI, per-device baselines).
  • espresso-suite - Android sibling.
  • appium-testing - cross-platform alternative when iOS + Android share tests.
  • junit-xml-analysis - downstream parser for JUnit-converted xcresult.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Builds a CI gate that fails the build on **new** WCAG / a11y violations introduced by a PR while grandfathering pre-existing violations on a per-rule / per-page baseline. Aggregates verdicts from axe-core / pa11y / Lighthouse a11y / WAVE / IBM Equal Access scans. Use when a project has accumulated a11y debt and a strict "zero violations" gate would block every PR - the ratchet pattern lets the team ship while preventing regressions.

中文简介正在准备中。当前显示原文说明。

testland/qa132026年10月20日 更新

Workflow skill that builds an A/B-test validity checklist from an experiment proposal, walking the canonical design-correctness gates - pre-registered OEC/power/guardrails, randomization unit + SRM check, assignment integrity, telemetry, peeking discipline, novelty/primacy, post-experiment SRM re-check - into a per-experiment checklist + sign-off form. Use when launching, auditing, or governing an experiment. For pitfall mechanics (guardrails, peeking) see experiment-results-interpreter's references; to read an already-valid result use experiment-results-interpreter; for per-SDK harness tests use experiment-sdk-testing - this gates DESIGN, not SDK code.

中文简介正在准备中。当前显示原文说明。

testland/qa132026年10月20日 更新

The single install-flow skill: the reference contract for the PWA install flow (installability gate fields, `beforeinstallprompt` handshake, per-platform paths - Android WebAPK / iOS Share menu / Firefox no-op - and the `display-mode` post-install signal, in references/install-flow-reference.md) plus the build-an-X workflow that emits the Add-to-Home-Screen suite. Walks the four-stage timeline, emitting one test per gate cell per [web.dev/articles/install-criteria][install-criteria], the deferred-prompt → `prompt()` → `userChoice` chain per [web.dev/articles/customize-install][customize-install], the iOS Safari manual-metadata branch (`apple-touch-icon`) per [web.dev/learn/pwa/installation][learn-pwa], and the post-install `(display-mode: standalone)` MQ assertion. Output: a Playwright spec with per-stage cells plus a coverage matrix. Use when a PWA's manifest, icons, or install handler change, when install conversion drops at an unknown stage, or when triaging a flaky install assertion.

中文简介正在准备中。当前显示原文说明。

testland/qa132026年10月20日 更新

Build-an-X workflow that uses an LLM to map existing tests to spec sections - given a spec doc + the test suite, the LLM identifies which tests cover which sections, surfaces uncovered sections (gap), and recommends specific tests to add. Output is a coverage matrix per spec ID. Scope is mapping tests that already exist and naming the gaps, not authoring tests for new acceptance criteria. Use when a spec doc and a test suite both exist but nobody can say which requirements are actually covered - before a release sign-off, an audit, or a decision about where to spend the next round of test effort.

中文简介正在准备中。当前显示原文说明。

testland/qa132026年10月20日 更新

Generates tests from natural-language specs (acceptance criteria, user stories, requirements) using an LLM, with confidence scoring per test case (LLM self-assessment plus heuristics: assertion quality, naming, completeness), batching uncertain cases for human review, and integration with the team's existing test framework. Use when the user asks to generate unit tests from acceptance criteria, convert user stories to test cases, automate test creation from requirements, or augment a spec-driven test suite with AI-generated stubs that are then curated before merge.

中文简介正在准备中。当前显示原文说明。

testland/qa132026年10月20日 更新

Configures Allure Report (test-runner adapter install, `allure-results` directory wiring, `categories.json` for failure classification, `history-trend.json` retention via the copy-history-between-runs pattern), runs the Allure CLI to convert `allure-results` to a static HTML site, and uploads the report as a CI artifact. Use when the team needs richer test reporting than JUnit XML - step-level attachments, per-test history, retry tracking, and severity / epic / feature labeling across framework-agnostic adapters (pytest, Jest, JUnit, TestNG, NUnit, Mocha). As a rich static HTML report generator, it is the open-source alternative to the sunset ExtentReports (JVM/.NET per-test HTML narrative); for hosted cross-run flakiness analytics rather than a static per-run report use currents-integration.

中文简介正在准备中。当前显示原文说明。

testland/qa132026年10月20日 更新

查看 testland 的全部技能

报告此技能的问题