# Geautomatiseerde iOS-app-testen Combineer het memory-systeem van Synapse met de Computer Control API om door LLM aangedreven iOS-app-tests te bouwen. De LLM herinnert testscenario's, leert van eerdere fouten, en past zich aan UI-wijzigingen aan. ## Architectuur ``` ┌──────────────┐ commands ┌──────────────┐ screenshots ┌──────────────┐ │ LLM Agent │ ─────────────▶│ Synapse │ ────────────────▶ │ iOS Sim │ │ (Claude) │ │ Computer │ ◀──────────────── │ (via agent) │ └──────────────┘ │ Control │ results └──────────────┘ │ └──────────────┘ │ store/recall ▼ ┌──────────────┐ │ Memories │ (test scenarios, past failures, UI patterns) └──────────────┘ ``` ## Vereisten - Synapse-account + Mind Key - Synapse MCP-server geconfigureerd in Claude Desktop - iOS Simulator met `screen-remote-agent` geïnstalleerd - Computer geregistreerd in Synapse (zie [Computer Control API](/docs/api/computers)) ## Stap 1: Registreer de Simulator-computer Op de Mac waarop iOS Simulator draait: ```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) ``` ## Stap 2: Sla testscenario's op in memory Sla herbruikbare testscenario's op als herinneringen: ```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") ``` ## Stap 3: Door LLM aangedreven testuitvoering In Claude Desktop (met Synapse MCP geconfigureerd): ``` 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 zal: 1. `memory_search` aanroepen om de `test_scenario_login_flow`-herinnering te vinden 2. `computer_screenshot` aanroepen om de huidige staat te zien 3. Elke stap uitvoeren via `computer_command_queue` (klik, typ) 4. Resultaten verifiëren via schermafbeeldingen 5. Eventuele fouten opslaan als `mistake`-herinneringen ## Stap 4: Zelfherstellende tests Wanneer een test faalt, sla de fout en het herstel op: ```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.") ``` De volgende keer dat de LLM de test uitvoert, haalt hij de fout op en past hij het herstel automatisch toe. ## Stap 5: Testresultaat-tracking Volg testruns als taken: ```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" }) ``` ## Veelvoorkomende commando's | Actie | Commando | |-------|----------| | Simulator starten | `xcrun simctl launch booted com.example.app` | | Schermafbeelding | `computer_screenshot` (via Synapse MCP) | | Tik op (x,y) | `computer_command_queue {type:"click", payload:{x,y}}` | | Typ tekst | `computer_command_queue {type:"type", payload:{text:"..."}}` | | Druk op Home | `computer_command_queue {type:"key", payload:{keys:["Cmd","Shift","H"]}}` | ## Best practices > [!TIP] > - **Sla UI-coördinaten op als herinneringen** — UI verandert, maar de LLM kan opnieuw leren > - **Gebruik accessibility-labels** — stabieler dan coördinaten > - **Sla testdata apart op** — gebruik variabelen voor gebruikersnamen, wachtwoorden > - **Draai tests in schone staat** — reset Simulator tussen runs > - **Log schermafbeeldingen bij fouten** — nuttig voor debugging ## Volgende stappen - [Zelfherstellende tests](/docs/guides/self-healing-tests) - [Computer Control API](/docs/api/computers) - [Memory-best-practices](/docs/guides/memory-best-practices)