# Automatisiertes iOS-App-Testing Kombiniere Synapses Memory-System mit der Computer-Control-API, um LLM-gesteuerte iOS-App-Tests zu bauen. Das LLM erinnert sich an Test-Szenarien, lernt aus vergangenen Fehlern und passt sich an UI-Änderungen an. ## Architektur ``` ┌──────────────┐ commands ┌──────────────┐ screenshots ┌──────────────┐ │ LLM Agent │ ─────────────▶│ Synapse │ ────────────────▶ │ iOS Sim │ │ (Claude) │ │ Computer │ ◀──────────────── │ (via agent) │ └──────────────┘ │ Control │ results └──────────────┘ │ └──────────────┘ │ store/recall ▼ ┌──────────────┐ │ Memories │ (test scenarios, past failures, UI patterns) └──────────────┘ ``` ## Voraussetzungen - Synapse-Konto + Mind Key - Synapse-MCP-Server in Claude Desktop konfiguriert - iOS-Simulator mit installiertem `screen-remote-agent` - Rechner in Synapse registriert (siehe [Computer-Control-API](/docs/api/computers)) ## Schritt 1: Simulator-Rechner registrieren Auf dem Mac, der den iOS-Simulator ausführt: ```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) ``` ## Schritt 2: Test-Szenarien im Memory speichern Wiederverwendbare Test-Szenarien als Memories speichern: ```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") ``` ## Schritt 3: LLM-gesteuerte Testausführung In Claude Desktop (mit konfiguriertem 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 wird: 1. `memory_search` aufrufen, um den `test_scenario_login_flow`-Memory zu finden 2. `computer_screenshot` aufrufen, um den aktuellen Zustand zu sehen 3. Jeden Schritt via `computer_command_queue` ausführen (Click, Type) 4. Ergebnisse via Screenshots verifizieren 5. Alle Fehlschläge als `mistake`-Memories speichern ## Schritt 4: Self-Healing-Tests Wenn ein Test fehlschlägt, speichere den Fehlschlag und die Recovery: ```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.") ``` Wenn das LLM den Test das nächste Mal ausführt, ruft es den Fehlschlag ab und wendet die Recovery automatisch an. ## Schritt 5: Test-Ergebnis-Tracking Testläufe als Tasks tracken: ```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" }) ``` ## Häufige Befehle | Aktion | Befehl | |--------|--------| | Simulator starten | `xcrun simctl launch booted com.example.app` | | Screenshot | `computer_screenshot` (via Synapse MCP) | | Tap at (x,y) | `computer_command_queue {type:"click", payload:{x,y}}` | | Text tippen | `computer_command_queue {type:"type", payload:{text:"..."}}` | | Home drücken | `computer_command_queue {type:"key", payload:{keys:["Cmd","Shift","H"]}}` | ## Best Practices > [!TIP] > - **UI-Koordinaten als Memories speichern** — UI ändert sich, aber das LLM kann neu lernen > - **Accessibility-Labels verwenden** — stabiler als Koordinaten > - **Testdaten separat speichern** — Variablen für Nutzernamen, Passwörter verwenden > - **Tests in clean state ausführen** — Simulator zwischen Läufen zurücksetzen > - **Screenshots für Fehlschläge loggen** — nützlich beim Debugging ## Nächste Schritte - [Self-Healing-Tests](/docs/guides/self-healing-tests) - [Computer-Control-API](/docs/api/computers) - [Memory-Best-Practices](/docs/guides/memory-best-practices)