xcuitest について
Swift 6で信頼性の高いXCUITest UIテストを書くためのリファレンススキルです。APIの解説や例、トラブルシューティングを検索しやすいローカルファイルにまとめています。
主な機能
- 01要素の検索と操作
- 02待機とアサーション
- 03Swift 6の並行処理ガイド
- 04スクリーンショットと起動設定
- 05権限とテストヘルパー
- 06トラブルシューティングとテストパターン
活用シーン
- 01XCUITestのテストケース作成
- 02非同期UI要素の処理
- 03権限とシステムアラートのテスト
- 04不安定なUIテストの調査
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ prisma-labs-dev/ apple-skills --skill xcuitestインストール後、Claude Code で/xcuitestを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
assertions.mdelement-queries.mdinteractions.mdlaunch-arguments.mdpatterns.mdpermissions.mdscreenshots.mdswift6-concurrency.mdtest-helpers.mdtroubleshooting.mdwaiting.mdxctest-index.mdxcuiapplication.mdxcuiautomation-index.mdxcuicoordinate.mdxcuielement.mdxcuielementquery.mdxcuiprotectedresource.mdxcuiscreenshot.md詳細
XCUITest リファレンス
Swift 6 で信頼性の高い XCUITest UI テストを書くための包括的なリファレンスです。
クイックリファレンス
// Basic test structure
@MainActor
final class MyUITests: XCTestCase {
var app: XCUIApplication!
override func setUp() {
super.setUp()
continueAfterFailure = false
app = XCUIApplication()
app.launch()
}
func testExample() {
let button = app.buttons["Submit"]
XCTAssertTrue(button.waitForExistence(timeout: 5))
button.tap()
}
}
トピックガイド
コード例付きの厳選ガイド(grep で検索しやすい形式):
| ファイル | 内容 |
|---|---|
| element-queries.md | 主要な API クラス:XCUIApplication、XCUIElement、XCUIElementQuery、XCUICoordinate |
| interactions.md | タップ、プレス、テキスト入力、スワイプ、座標ベースのジェスチャーなど |
| waiting.md | waitForExistence、XCTWaiter、非存在、プロパティの待機、Xcode 26 の KeyPath による待機 |
| swift6-concurrency.md | Swift 6 の厳格な並行処理:@MainActor テストクラス、async setUp/tearDown、nonisolated |
| assertions.md | XCTAssert のパターン、カスタムメッセージ、存在チェック |
| screenshots.md | スクリーンショット、XCTAttachment、失敗時のスクリーンショット、.xcresult からの抽出 |
| launch-arguments.md | 起動引数/環境変数、UserDefaults のオーバーライド、ローカリゼーションとアクセシビリティのテスト |
| permissions.md | resetAuthorizationStatus、XCUIProtectedResource、割り込みモニター、SpringBoard/システムのアラート |
| test-helpers.md | Page Object Model、再利用可能なヘルパー、タイムアウト定数 |
| troubleshooting.md | よくある失敗(要素が見つからない、不安定なテスト)と Xcode 26/iOS 26 の新機能 |
| patterns.md | 高度なパターン:ベーステストクラス、システムダイアログ、スクロール/待機、デバッグ、テストの構成 |
ダウンロード済みのリファレンスファイル
Apple のドキュメントページをローカルで利用できます:
| ファイル | 内容 |
|---|---|
| xctest-index.md | XCTest フレームワークの全インデックス |
| xcuiautomation-index.md | XCUIAutomation フレームワークの全インデックス |
| xcuiapplication.md | XCUIApplication クラス |
| xcuielement.md | XCUIElement クラス |
| xcuielementquery.md | XCUIElementQuery クラス |
| xcuicoordinate.md | XCUICoordinate クラス |
| xcuiprotectedresource.md | XCUIProtectedResource 列挙型 |
| xcuiscreenshot.md | XCUIScreenshot クラス |
ソース
Apple のドキュメント
- XCTest | Apple Developer Documentation
- XCUIAutomation | Apple Developer Documentation
- XCUIElementQuery | Apple Developer Documentation
- waitForExistence | Apple Developer Documentation
- wait(for:toEqual:timeout:) | Apple Developer Documentation
- resetAuthorizationStatus(for:) | Apple Developer Documentation
- XCUIProtectedResource | Apple Developer Documentation
- XCUIScreenshot | Apple Developer Documentation
WWDC セッション
コミュニティリソース
- XCTest と @MainActor | Quality Coding
- Swift 6 の XCTest における setUp() と tearDown() の問題 | Swift Forums
- XCTest での待機 | Masilotti.com
- UI テストのチートシート | Masilotti.com
- XCUIElement のアクションとジェスチャ | Apps Developer Blog
- 起動引数を使った UI テストの設定 | polpiella.dev
- Xcode 16 の UI テストの改善 | Jesse Squires
Apple のドキュメントをさらに取得する
- まず、このスキルのローカル
.mdファイルを検索します。 - 該当するトピックが見つからない場合は、利用可能なほかのインストール済み Apple スキルを、名前、説明、または
SKILL.mdのフロントマターから確認し、そのローカルファイルを grep します。新しいドキュメントをインターネットから取得するよりも速く、使用するコンテキストも少なくて済みます。 - 該当するページがインストール済みスキルにない場合は、ローカルの XCTest または XCUIAutomation インデックスにある関連ドキュメントのパスを使い、
sosumi.aiの Markdown ミラーを参照します。たとえば、/documentation/xcuiautomation/xcuielementはhttps://sosumi.ai/documentation/xcuiautomation/xcuielementに対応します。
コメント
Markdown 対応