Skip to main content

Zautomatyzowane testowanie aplikacji iOS

Wykorzystanie Synapse i Computer Control API do automatyzacji testów aplikacji iOS przez Simulator.


Zautomatyzowane testowanie aplikacji iOS

Połączenie systemu pamięci Synapse z Computer Control API pozwala budować testy aplikacji iOS sterowane przez LLM. LLM pamięta scenariusze testowe, uczy się na przeszłych błędach i dostosowuje się do zmian UI.

Architektura

┌──────────────┐    commands    ┌──────────────┐    screenshots    ┌──────────────┐
│  LLM Agent   │ ─────────────▶│  Synapse     │ ────────────────▶ │  iOS Sim     │
│  (Claude)    │               │  Computer    │ ◀──────────────── │  (via agent) │
└──────────────┘               │  Control     │    results        └──────────────┘
       │                       └──────────────┘
       │ store/recall
       ▼
┌──────────────┐
│  Memories    │ (test scenarios, past failures, UI patterns)
└──────────────┘

Wymagania wstępne

  • Konto Synapse i Mind Key
  • Serwer MCP Synapse skonfigurowany w Claude Desktop
  • iOS Simulator z zainstalowanym screen-remote-agent
  • Komputer zarejestrowany w Synapse (patrz Computer Control API)

Krok 1: Rejestracja komputera-symulatora

Na Macu z uruchomionym iOS Simulator:

# Pobranie kodu instalacyjnego z 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_..." }

# Uruchomienie screen-remote-agent na Macu
# (używa kodu instalacyjnego do rejestracji)

Krok 2: Zapis scenariuszy testowych w pamięci

Zapisanie wielokrotnego użytku scenariuszy testowych jako wspomnień:

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")

Krok 3: Wykonanie testu sterowane przez LLM

W Claude Desktop (z skonfigurowanym MCP Synapse):

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 wykona:

  1. Wywoła memory_search, aby znaleźć wspomnienie test_scenario_login_flow
  2. Wywoła computer_screenshot, aby zobaczyć aktualny stan
  3. Wykona każdy krok przez computer_command_queue (kliknięcie, wpisanie)
  4. Zweryfikuje wyniki przez zrzuty ekranu
  5. Zapisze błędy jako wspomnienia mistake

Krok 4: Testy samonaprawiające

Gdy test się nie powiedzie, zapisać błąd i sposób odzyskiwania:

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"
        })

# Przykład
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.")

Przy następnym uruchomieniu testu LLM przypomni sobie błąd i automatycznie zastosuje odzyskiwanie.

Krok 5: Śledzenie wyników testów

Śledzenie uruchomień testów jako zadań:

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"
        })

Typowe polecenia

Akcja Polecenie
Uruchomienie Simulator xcrun simctl launch booted com.example.app
Zrzut ekranu computer_screenshot (przez MCP Synapse)
Stuknięcie w (x,y) computer_command_queue {type:"click", payload:{x,y}}
Wpisanie tekstu computer_command_queue {type:"type", payload:{text:"..."}}
Wciśnięcie Home computer_command_queue {type:"key", payload:{keys:["Cmd","Shift","H"]}}

Najlepsze praktyki

Następne kroki