/mobile-plugin:ios-test-designfrom mobile-plugin
XCTest/XCUITestを用いたiOSアプリのテスト設計支援スキル。テスト戦略立案、モック/スタブ設計、テストデータ管理、カバレッジ分析を包括的にサポート。Use when: iOSテスト設計、XCTest実装、UITest作成、テストカバレッジ向上、テスト戦略立案、テストダブル設計。
Ships in mobile-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
XCTestおよびXCUITestを活用したiOSアプリケーションのテスト設計を支援するスキル。 デトロイト学派寄りのアプローチを採用し、実際のコンポーネント連携をテストすることで、信頼性の高いテストスイートを構築する。
以下の状況でこのスキルを起動する:
| 評価項目 | 確認内容 |
|---|---|
| 依存性注入 | コンストラクタ/プロパティ経由で差し替え可能か |
| 副作用の分離 | I/O操作がプロトコル経由で抽象化されているか |
| 状態の観測 | 内部状態の変化を外部から検証可能か |
| 決定論性 | 同一入力に対して同一出力が保証されるか |
| レベル | 対象 | テストダブル | 実行頻度 |
|---|---|---|---|
| Unit | ビジネスロジック、ViewModel、Utility | スタブ/モック | 常時 |
| Integration | UseCase + Repository、View + ViewModel | スタブ(外部境界のみ) | PR/CI |
| UI | 主要ユーザーフロー | なし(実環境に近づける) | デイリー/リリース |
詳細は references/xctest-patterns.md を参照。
final class SampleTests: XCTestCase {
// MARK: - Properties
private var sut: SystemUnderTest!
private var mockDependency: MockDependency!
// MARK: - Setup/Teardown
override func setUp() {
super.setUp()
mockDependency = MockDependency()
sut = SystemUnderTest(dependency: mockDependency)
}
override func tearDown() {
sut = nil
mockDependency = nil
super.tearDown()
}
// MARK: - Tests
func test_methodName_condition_expectedBehavior() {
// Given(前提条件)
let input = ...
// When(実行)
let result = sut.method(input)
// Then(検証)
XCTAssertEqual(result, expected)
}
}
test_<対象メソッド>_<条件>_<期待される振る舞い>
例:
test_login_withValidCredentials_returnsSuccess
test_fetchUser_whenNetworkError_throwsError
test_calculate_withNegativeInput_returnsZero
詳細は references/test-doubles.md を参照。
// 抽象化されたプロトコル
protocol UserRepositoryProtocol {
func fetch(id: String) async throws -> User
}
// 本番実装
final class UserRepository: UserRepositoryProtocol { ... }
// テストダブル
final class MockUserRepository: UserRepositoryProtocol {
var fetchResult: Result<User, Error> = .success(User.stub)
var fetchCallCount = 0
var lastFetchedId: String?
func fetch(id: String) async throws -> User {
fetchCallCount += 1
lastFetchedId = id
return try fetchResult.get()
}
}
詳細は references/xcuitest-patterns.md を参照。
// Page Object
final class LoginPage {
private let app: XCUIApplication
var emailField: XCUIElement { app.textFields["email"] }
var passwordField: XCUIElement { app.secureTextFields["password"] }
var loginButton: XCUIElement { app.buttons["login"] }
init(app: XCUIApplication) {
self.app = app
}
func login(email: String, password: String) -> HomePage {
emailField.tap()
emailField.typeText(email)
passwordField.tap()
passwordField.typeText(password)
loginButton.tap()
return HomePage(app: app)
}
}
| 要素 | 命名規則 | 例 |
|---|---|---|
| 画面 | <screen>_screen | login_screen |
| ボタン | <action>_button | submit_button |
| テキストフィールド | <field>_field | email_field |
| ラベル | <content>_label | error_label |
| セル | <item>_cell_<index> | user_cell_0 |
詳細は references/test-data.md を参照。
enum UserFactory {
static func make(
id: String = UUID().uuidString,
name: String = "Test User",
email: String = "[email protected]",
isActive: Bool = true
) -> User {
User(id: id, name: name, email: email, isActive: isActive)
}
static var activeUser: User { make(isActive: true) }
static var inactiveUser: User { make(isActive: false) }
}
Tests/
├── Fixtures/
│ ├── JSON/
│ │ ├── user_response.json
│ │ └── error_response.json
│ └── Stubs/
│ └── UserStub.swift
Cmd + U でテスト実行# テスト設計書: <機能名>
## 1. テスト対象
- クラス/構造体: `ClassName`
- 責務: 〇〇を行う
## 2. テスト戦略
- テストレベル: Unit / Integration / UI
- テストダブル: 使用する依存のリスト
## 3. テストケース一覧
| ID | カテゴリ | テスト内容 | 期待結果 |
|----|---------|----------|---------|
| TC-001 | 正常系 | ... | ... |
| TC-002 | 異常系 | ... | ... |
## 4. テストダブル設計
- MockXxx: 〇〇の呼び出しを検証
- StubYyy: 〇〇の値を返す
## 5. テストデータ
- Factory: XxxFactory
- Fixture: xxx_response.json
import XCTest
@testable import TargetModule
final class FeatureTests: XCTestCase {
// 上記パターンに従ったテストコード
}
Date() 直接使用ではなく注入するWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub caphtech/claude-marketplace --plugin mobile-plugin10 skills in this plugin
/flutter-widget-splittingFlutter Widgetの肥大化を、責務分離・共通化・Riverpod境界の整理でリファクタリングする。build()が長い、Widgetを分割したい、Riverpodのwatch/read/listen/select境界を見直したい、共通化したい、Flutter UIを整理したい時に使用。/ios-archiveアーカイブ・配布支援。App Store Connect、TestFlight、Ad Hoc/Enterprise配布。使用タイミング: (1) App Storeへの提出準備時、(2) TestFlight配布時、(3) Ad Hoc/Enterprise配布時、(4) CI/CDでの自動配布設定時/ios-ia-navigationiOSアプリの情報設計(IA)と画面遷移(ナビゲーション)を設計するスキル。Apple HIGとWWDCセッションに基づき、タブ/階層push/モーダルを情報階層とタスク構造から逆算して選定し、根拠と未確定事項を可視化しながら設計を完遂する。使用タイミング: (1) 新規アプリの情報設計時、(2) 画面遷移設計時、(3) 「IAを設計したい」「ナビゲーション構造を決めたい」、(4) iPad/iPhone両対応の構造設計時、(5) ディープリンク対応設計時、(6) 既存アプリのリファクタリング時Other plugins' skills for the same job