Communitygithub.com

ComeOnOliver/skillshub

Xcode 26 での UI テスト録画のセットアップ、記録されたテストの安定性向上、マルチ構成リプレイ用のテスト計画の構成に使用します。WWDC 2025-344「録画、リプレイ、レビュー」に基づいています。

skillshub とは?

このスキルは、Xcode 26 で導入された「Recording UI Automation」機能を活用し、ユーザー操作の録画を通じて UI テストを作成するための包括的なガイドです。WWDC 2025-344 に基づき、「録画(Record)」「リプレイ(Replay)」「レビュー(Review)」の3フェーズワークフローを解説します。まず、Xcode のデバッグツールを使い、シミュレーター上でのタップやテキスト入力などの操作を Swift テストコードとして自動生成します。次に、生成されたコードは不安定な場合が多いため、アクセシビリティ識別子の追加、waitForExistence による待機、アサーションの追加、短いクエリの使用など、安定性を高めるための具体的な強化手法を提供します。さらに、テスト計画(Test Plan)を使用して異なる言語、地域、デバイス構成でテストをリプレイする方法や、テスト結果のビデオ録画やスクリーンショットを確認するレビュープロセスもカバーします。最後に、CI 環境での失敗を防ぐためのトラブルシューティングや、アンチパターンについても言及しており、堅牢な UI 自動化テストを構築したい開発者や QA エンジニアにとって非常に有用です。

対応~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/CharlesWiltgen/Axiom/axiom-ui-recording

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Recording UI Automation (Xcode 26+)

Xcode 26 の Recording UI Automation 機能のガイドです。ユーザー操作の録画を通じて UI テストを作成します。

3つのフェーズからなるワークフロー

WWDC 2025-344 より:

┌─────────────────────────────────────────────────────────────┐
│                   UI Automation ワークフロー                 │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  1. 録画 (RECORD) ────► シミュレーターでアプリを操作            │
│                          Xcode が Swift テストコードとしてキャプチャ│
│                                                             │
│  2. リプレイ (REPLAY) ───► デバイス、言語、構成をまたいで実行      │
│                           テスト計画を使用したマルチ構成        │
│                                                             │
│  3. レビュー (REVIEW) ──► テストレポートでビデオ録画を確認        │
│                           スクリーンショットで障害を分析        │
│                                                             │
└─────────────────────────────────────────────────────────────┘

フェーズ1: 録画

録画の開始

  1. Xcode で UI テストファイルを開く
  2. カーソルをテストメソッド内に配置する
  3. デバッグ → UI Automation を録画(または録画ボタンを使用)
  4. アプリがシミュレーターで起動する
  5. 操作を実行 – Xcode がコードを生成する
  6. 完了したら録画を停止する

録画されるもの

  • タップ: ボタン、セル、コントロール
  • テキスト入力: テキストフィールド
  • スワイプとスクロール
  • ジェスチャー: ピンチ、ローテート
  • ハードウェアボタン操作: Home、音量

生成されるコード例

// Xcode が操作からこのコードを生成
func testLoginFlow() {
    let app = XCUIApplication()
    app.launch()

    // 録画: メールフィールドをタップ、メールを入力
    app.textFields["Email"].tap()
    app.textFields["Email"].typeText("[email protected]")

    // 録画: パスワードフィールドをタップ、パスワードを入力
    app.secureTextFields["Password"].tap()
    app.secureTextFields["Password"].typeText("password123")

    // 録画: ログインボタンをタップ
    app.buttons["Login"].tap()
}

録画されたコードの強化

重要: 録画されたコードは多くの場合脆弱です。安定性を高めるために必ず強化してください。

1. アクセシビリティ識別子を追加する

録画コードはラベルを使用するため、ローカライズで壊れます:

// 録画されたコード(脆弱 – ローカライズで壊れる)
app.buttons["Login"].tap()

// 強化されたコード(安定 – 識別子を使用)
app.buttons["loginButton"].tap()

アプリコードに識別子を追加:

// SwiftUI
Button("ログイン") { ... }
    .accessibilityIdentifier("loginButton")

// UIKit
loginButton.accessibilityIdentifier = "loginButton"

2. waitForExistence を追加する

録画コードは要素がすぐに存在することを前提としています:

// 録画されたコード(アプリが遅いと失敗する可能性あり)
app.buttons["Login"].tap()

// 強化されたコード(要素を待機)
let loginButton = app.buttons["loginButton"]
XCTAssertTrue(loginButton.waitForExistence(timeout: 5))
loginButton.tap()

3. アサーションを追加する

録画コードはアクションのみを実行し、検証は行いません:

// 録画されたコード(検証なし)
app.buttons["Login"].tap()

// 強化されたコード(アサーションあり)
app.buttons["loginButton"].tap()
let welcomeLabel = app.staticTexts["welcomeLabel"]
XCTAssertTrue(welcomeLabel.waitForExistence(timeout: 10),
              "ログイン後、ウェルカム画面が表示される必要があります")

4. 短いクエリを使用する

録画コードは過度に具体的なクエリを使う場合があります:

// 録画されたコード(詳細すぎる)
app.tables.cells.element(boundBy: 0).buttons["Action"].tap()

// 強化されたコード(よりシンプル)
app.buttons["actionButton"].tap()

クエリ選択のガイドライン

WWDC 2025-344 より:

シナリオ問題解決策
ローカライズされた文字列"Login" が言語によって変わるaccessibilityIdentifier を使用する
深くネストしたビュー長いクエリチェーンは壊れやすい可能な限り短いクエリを使用する
動的コンテンツセルの内容が変わる識別子または汎用クエリを使用する
複数のマッチクエリが多くの要素を返す一意の識別子を追加する

ベストプラクティス

  1. ラベルよりも識別子を優先する
  2. 動作する最短のクエリを使用する
  3. インデックスベースのクエリを避ける(element(boundBy: 0))
  4. 動的コンテンツに識別子を追加する

フェーズ2: テスト計画によるリプレイ

テスト計画を使用すると、同じテストを複数の構成で実行できます。

テスト計画の作成

  1. ファイル → 新規 → ファイル → テスト計画
  2. テストターゲットを追加する
  3. 構成を設定する

テスト計画の構造

{
  "configurations": [
    {
      "name": "iPhone - English",
      "options": {
        "targetForVariableExpansion": {
          "containerPath": "container:MyApp.xcodeproj",
          "identifier": "MyApp"
        },
        "language": "en",
        "region": "US"
      }
    },
    {
      "name": "iPhone - Spanish",
      "options": {
        "language": "es",
        "region": "ES"
      }
    },
    {
      "name": "iPhone - ダークモード",
      "options": {
        "userInterfaceStyle": "dark"
      }
    },
    {
      "name": "iPad - ランドスケープ",
      "options": {
        "defaultTestExecutionTimeAllowance": 120,
        "testTimeoutsEnabled": true
      }
    }
  ],
  "defaultOptions": {
    "targetForVariableExpansion": {
      "containerPath": "container:MyApp.xcodeproj",
      "identifier": "MyApp"
    }
  },
  "testTargets": [
    {
      "target": {
        "containerPath": "container:MyApp.xcodeproj",
        "identifier": "MyAppUITests",
        "name": "MyAppUITests"
      }
    }
  ],
  "version": 1
}

構成オプション

オプション目的
languageローカライゼーションのテスト
region地域の書式設定のテスト
userInterfaceStyleダーク/ライトモードのテスト
targetForVariableExpansion構成のためのアプリターゲット
testTimeoutsEnabledタイムアウト強制の有効化
defaultTestExecutionTimeAllowanceタイムアウト(秒)

テスト計画の実行

# コマンドライン
xcodebuild test \
  -scheme "MyApp" \
  -testPlan "MyTestPlan" \
  -destination "platform=iOS Simulator,name=iPhone 16" \
  -resultBundlePath /tmp/results.xcresult

# Xcode 内
# プロダクト → テスト計画 → 計画を選択
# その後 Cmd+U でテストを実行

フェーズ3: レビュー

テストレポートの機能

テスト完了後:

  1. テスト結果を表示(レポートナビゲーター)
  2. 各テストのビデオ録画を視聴
  3. 障害ポイントのスクリーンショットを確認
  4. アクションのタイムラインを分析

アタッチメントの有効化

テスト計画またはスキーム内:

"options": {
  "systemAttachmentLifetime": "keepAlways",
  "userAttachmentLifetime": "keepAlways"
}

カスタムスクリーンショットの取得

func testCheckout() {
    // ... アクション ...

    // 特定のポイントで手動スクリーンショット
    let screenshot = app.screenshot()
    let attachment = XCTAttachment(screenshot: screenshot)
    attachment.name = "チェックアウト確認"
    attachment.lifetime = .keepAlways
    add(attachment)
}

共通パターン

ログインフローのテンプレート

func testLoginWithValidCredentials() throws {
    let app = XCUIApplication()
    app.launch()

    // ログイン画面へ移動
    let showLoginButton = app.buttons["showLoginButton"]
    XCTAssertTrue(showLoginButton.waitForExistence(timeout: 5))
    showLoginButton.tap()

    // 認証情報を入力
    let emailField = app.textFields["emailTextField"]
    XCTAssertTrue(emailField.waitForExistence(timeout: 5))
    emailField.tap()
    emailField.typeText("[email protected]")

    let passwordField = app.secureTextFields["passwordTextField"]
    passwordField.tap()
    passwordField.typeText("password123")

    // 送信
    app.buttons["loginButton"].tap()

    // 成功を確認
    let welcomeScreen = app.staticTexts["welcomeLabel"]
    XCTAssertTrue(welcomeScreen.waitForExistence(timeout: 10))
}

ナビゲーションフローのテンプレート

func testNavigateToSettings() throws {
    let app = XCUIApplication()
    app.launch()

    // タブバーアイテムを開く
    app.tabBars.buttons["設定"].tap()

    // ナビゲーションを確認
    let settingsTitle = app.navigationBars["設定"]
    XCTAssertTrue(settingsTitle.waitForExistence(timeout: 5))

    // さらに深く移動
    app.tables.cells["アカウント"].tap()
    XCTAssertTrue(app.navigationBars["アカウント"].exists)
}

フォームバリデーションのテンプレート

func testFormValidation() throws {
    let app = XCUIApplication()
    app.launch()

    // 空のフォームを送信
    app.buttons["submitButton"].tap()

    // エラーが表示されることを確認
    let errorAlert = app.alerts["エラー"]
    XCTAssertTrue(errorAlert.waitForExistence(timeout: 5))
    XCTAssertTrue(errorAlert.staticTexts["すべての項目を入力してください"].exists)

    // アラートを閉じる
    errorAlert.buttons["OK"].tap()
}

トラブルシューティング

録画が開始しない

  1. テストメソッド内にいることを確認する
  2. シミュレーターが利用可能か確認する
  3. アプリがビルドおよび実行されることを確認する
  4. Xcode を再起動してみる

録画されたコードが動作しない

  1. インタラクションの前に waitForExistence を追加する
  2. アクセシビリティ識別子が設定されているか確認する
  3. クエリを最短の形式に簡略化する
  4. アプリを手動で実行してフローが動作するか確認する

ローカルではテストが成功するが、CI で失敗する

  1. 低速な CI マシン向けに タイムアウトを増やす
  2. アニメーション用に 明示的な待機を追加する
  3. シミュレーター構成が一致するか確認する
  4. テストセットアップで アニメーションを無効にする:
    app.launchArguments = ["--disable-animations"]
    

アンチパターン

CI で生の録画コードを使用しない

// 悪い例 – 生の録画コード
app.buttons["Login"].tap()
app.textFields["Email"].typeText("[email protected]")

// 良い例 – CI 向けに強化
let loginButton = app.buttons["loginButton"]
XCTAssertTrue(loginButton.waitForExistence(timeout: 10))
loginButton.tap()

座標をハードコードしない

// 悪い例 – 録画からの座標
app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()

// 良い例 – 要素クエリを使用
app.buttons["centerButton"].tap()

アサーションをスキップしない

// 悪い例 – アクションのみ
app.buttons["Login"].tap()
sleep(2)  // うまくいくことを期待

// 良い例 – 結果を確認
app.buttons["loginButton"].tap()
XCTAssertTrue(app.staticTexts["ようこそ"].waitForExistence(timeout: 10))

リソース

WWDC: 2025-344, 2024-10206, 2019-413

ドキュメント: /xcode/testing/recording-ui-tests, /xctest/xcuiapplication

スキル: axiom-xctest-automation, axiom-ui-testing

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

関連スキル