# 자동화된 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](/docs/api/computers) 참조) ## 1단계: Simulator 컴퓨터 등록 iOS Simulator를 실행 중인 Mac에서: ```bash # 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단계: 메모리에 테스트 시나리오 저장 재사용 가능한 테스트 시나리오를 메모리로 저장: ```python 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는 다음을 수행합니다: 1. `memory_search`를 호출하여 `test_scenario_login_flow` 메모리 찾기 2. `computer_screenshot`을 호출하여 현재 상태 보기 3. `computer_command_queue` (click, type)를 통해 각 단계 실행 4. 스크린샷을 통해 결과 검증 5. 모든 실패를 `mistake` 메모리로 저장 ## 4단계: 자가 치유 테스트 테스트가 실패하면 실패와 복구를 저장: ```python 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단계: 테스트 결과 추적 테스트 실행을 작업으로 추적: ```python 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"]}}` | ## 모범 사례 > [!TIP] > - **UI 좌표를 메모리로 저장** — UI는 변경되지만, LLM이 다시 학습할 수 있음 > - **접근성 라벨 사용** — 좌표보다 안정적 > - **테스트 데이터를 분리하여 저장** — 사용자 이름, 비밀번호에 변수 사용 > - **깨끗한 상태에서 테스트 실행** — 실행 간 Simulator 재설정 > - **실패에 대한 스크린샷 로그** — 디버깅에 유용 ## 다음 단계 - [자가 치유 테스트](/docs/guides/self-healing-tests) - [Computer Control API](/docs/api/computers) - [메모리 모범 사례](/docs/guides/memory-best-practices)