iOS アプリの自動テスト
Synapse + Computer Control API を使用して Simulator 経由で iOS アプリテストを自動化。
iOS アプリの自動テスト
Synapse のメモリシステムと Computer Control API を組み合わせて、LLM 駆動の iOS アプリテストを構築します。LLM はテストシナリオを記憶し、過去の失敗から学習し、UI 変更に適応します。
アーキテクチャ
┌──────────────┐ commands ┌──────────────┐ screenshots ┌──────────────┐
│ LLM Agent │ ─────────────▶│ Synapse │ ────────────────▶ │ iOS Sim │
│ (Claude) │ │ Computer │ ◀──────────────── │ (via agent) │
└──────────────┘ │ Control │ results └──────────────┘
│ └──────────────┘
│ store/recall
▼
┌──────────────┐
│ Memories │ (test scenarios, past failures, UI patterns)
└──────────────┘前提条件
- Synapse アカウント + Mind Key
- Claude Desktop で構成された Synapse MCP サーバー
screen-remote-agentをインストールした iOS Simulator- Synapse に登録されたコンピュータ(Computer Control API を参照)
ステップ 1:Simulator コンピュータの登録
iOS Simulator を実行する Mac 上で:
# Get install code from Synapse
curl -X POST https://synapse.schaefer.zone/computers/install-code \
-H "Authorization: Bearer YOUR_MIND_KEY" \
-d '{"computer_name":"ios-sim"}'
# → { "install_code": "ic_..." }
# Run screen-remote-agent on the Mac
# (uses the install code to register)ステップ 2:テストシナリオをメモリに保存
再利用可能なテストシナリオをメモリとして保存します。
import requests
def store_test_scenario(name, steps, app):
requests.post(f"{URL}/memory",
headers={"Authorization": f"Bearer {MIND_KEY}"},
json={
"category": "skill",
"key": f"test_scenario_{name}",
"content": f"App: {app}\nSteps:\n" + "\n".join(steps),
"tags": ["test", "ios", app],
"priority": "high"
})
store_test_scenario("login_flow", [
"Launch app",
"Tap email field",
"Type test@example.com",
"Tap password field",
"Type password123",
"Tap Login button",
"Verify home screen appears"
], "MyApp")ステップ 3:LLM 駆動のテスト実行
Claude Desktop で(Synapse MCP を構成済み):
Run the login_flow test scenario on the iOS Simulator.
Take a screenshot after each step and verify the expected UI.
If any step fails, store the failure as a memory so we can
avoid it next time.Claude は以下を行います。
memory_searchを呼び出してtest_scenario_login_flowメモリを見つけるcomputer_screenshotを呼び出して現在の状態を確認- 各ステップを
computer_command_queue(click、type)経由で実行 - スクリーンショットで結果を検証
- 失敗があれば
mistakeメモリとして保存
ステップ 4:自己修復テスト
テスト失敗時に、失敗と復旧を保存します。
def store_test_failure(scenario, step, error, recovery):
requests.post(f"{URL}/memory",
headers={"Authorization": f"Bearer {MIND_KEY}"},
json={
"category": "mistake",
"key": f"failure_{scenario}_{step}",
"content": f"Scenario: {scenario}\nStep: {step}\nError: {error}\nRecovery: {recovery}",
"tags": ["test", "failure", "ios", scenario],
"priority": "high"
})
# Example
store_test_failure("login_flow", "tap_login",
"Login button not found at expected coordinates",
"Button moved due to new logo. Search by accessibility label instead.")次回 LLM がテストを実行する際、失敗を再取得し、復旧を自動的に適用します。
ステップ 5:テスト結果の追跡
テスト実行をタスクとして追跡します。
def track_test_run(scenario, status, duration):
requests.post(f"{URL}/mind/task",
headers={"Authorization": f"Bearer {MIND_KEY}",
"Content-Type": "application/json"},
json={
"title": f"Test: {scenario}",
"description": f"Status: {status}, Duration: {duration}s",
"priority": "normal"
})よくあるコマンド
| アクション | コマンド |
|---|---|
| Simulator 起動 | xcrun simctl launch booted com.example.app |
| スクリーンショット | computer_screenshot(Synapse MCP 経由) |
| (x,y) をタップ | computer_command_queue {type:"click", payload:{x,y}} |
| テキスト入力 | computer_command_queue {type:"type", payload:{text:"..."}} |
| Home を押す | computer_command_queue {type:"key", payload:{keys:["Cmd","Shift","H"]}} |