{"title":"Tests automatisés d'applications iOS","slug":"automated-testing-ios","category":"guides","summary":"Utilisez Synapse + l'API Computer Control pour automatiser les tests d'applications iOS via Simulator.","audience":["human","llm"],"tags":["guide","ios","testing","automation"],"difficulty":"advanced","updated":"2026-06-27","word_count":353,"read_minutes":2,"lang":"fr","translated":true,"requested_lang":"fr","content_markdown":"\n# Tests automatisés d'applications iOS\n\nCombinez le système de mémoire de Synapse avec l'API Computer Control pour construire\ndes tests d'applications iOS pilotés par LLM. Le LLM se souvient des scénarios de\ntest, apprend des échecs passés et s'adapte aux changements d'interface.\n\n## Architecture\n\n```\n┌──────────────┐    commands    ┌──────────────┐    screenshots    ┌──────────────┐\n│  LLM Agent   │ ─────────────▶│  Synapse     │ ────────────────▶ │  iOS Sim     │\n│  (Claude)    │               │  Computer    │ ◀──────────────── │  (via agent) │\n└──────────────┘               │  Control     │    results        └──────────────┘\n       │                       └──────────────┘\n       │ store/recall\n       ▼\n┌──────────────┐\n│  Memories    │ (test scenarios, past failures, UI patterns)\n└──────────────┘\n```\n\n## Prérequis\n\n- Compte Synapse + Mind Key\n- Serveur MCP Synapse configuré dans Claude Desktop\n- iOS Simulator avec `screen-remote-agent` installé\n- Ordinateur enregistré dans Synapse (voir [API Computer Control](/docs/api/computers))\n\n## Étape 1 : enregistrer l'ordinateur Simulator\n\nSur le Mac exécutant iOS Simulator :\n\n```bash\n# Obtenir le code d'installation de Synapse\ncurl -X POST https://synapse.schaefer.zone/computers/install-code \\\n  -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n  -d '{\"computer_name\":\"ios-sim\"}'\n# → { \"install_code\": \"ic_...\" }\n\n# Exécuter screen-remote-agent sur le Mac\n# (utilise le code d'installation pour s'enregistrer)\n```\n\n## Étape 2 : stocker les scénarios de test en mémoire\n\nStockez les scénarios de test réutilisables en tant que mémoires :\n\n```python\nimport requests\n\ndef store_test_scenario(name, steps, app):\n    requests.post(f\"{URL}/memory\",\n        headers={\"Authorization\": f\"Bearer {MIND_KEY}\"},\n        json={\n            \"category\": \"skill\",\n            \"key\": f\"test_scenario_{name}\",\n            \"content\": f\"App: {app}\\nSteps:\\n\" + \"\\n\".join(steps),\n            \"tags\": [\"test\", \"ios\", app],\n            \"priority\": \"high\"\n        })\n\nstore_test_scenario(\"login_flow\", [\n    \"Launch app\",\n    \"Tap email field\",\n    \"Type test@example.com\",\n    \"Tap password field\",\n    \"Type password123\",\n    \"Tap Login button\",\n    \"Verify home screen appears\"\n], \"MyApp\")\n```\n\n## Étape 3 : exécution de test pilotée par LLM\n\nDans Claude Desktop (avec MCP Synapse configuré) :\n\n```\nRun the login_flow test scenario on the iOS Simulator.\nTake a screenshot after each step and verify the expected UI.\nIf any step fails, store the failure as a memory so we can\navoid it next time.\n```\n\nClaude va :\n\n1. Appeler `memory_search` pour trouver la mémoire `test_scenario_login_flow`\n2. Appeler `computer_screenshot` pour voir l'état actuel\n3. Exécuter chaque étape via `computer_command_queue` (clic, saisie)\n4. Vérifier les résultats via captures d'écran\n5. Stocker tout échec en tant que mémoires `mistake`\n\n## Étape 4 : tests auto-réparables\n\nQuand un test échoue, stockez l'échec et la récupération :\n\n```python\ndef store_test_failure(scenario, step, error, recovery):\n    requests.post(f\"{URL}/memory\",\n        headers={\"Authorization\": f\"Bearer {MIND_KEY}\"},\n        json={\n            \"category\": \"mistake\",\n            \"key\": f\"failure_{scenario}_{step}\",\n            \"content\": f\"Scenario: {scenario}\\nStep: {step}\\nError: {error}\\nRecovery: {recovery}\",\n            \"tags\": [\"test\", \"failure\", \"ios\", scenario],\n            \"priority\": \"high\"\n        })\n\n# Exemple\nstore_test_failure(\"login_flow\", \"tap_login\",\n    \"Login button not found at expected coordinates\",\n    \"Button moved due to new logo. Search by accessibility label instead.\")\n```\n\nLa prochaine fois que le LLM exécute le test, il rappelle l'échec et applique la\nrécupération automatiquement.\n\n## Étape 5 : suivi des résultats de test\n\nSuivez les exécutions de test en tant que tâches :\n\n```python\ndef track_test_run(scenario, status, duration):\n    requests.post(f\"{URL}/mind/task\",\n        headers={\"Authorization\": f\"Bearer {MIND_KEY}\",\n                 \"Content-Type\": \"application/json\"},\n        json={\n            \"title\": f\"Test: {scenario}\",\n            \"description\": f\"Status: {status}, Duration: {duration}s\",\n            \"priority\": \"normal\"\n        })\n```\n\n## Commandes courantes\n\n| Action | Commande |\n|--------|---------|\n| Lancer Simulator | `xcrun simctl launch booted com.example.app` |\n| Capture d'écran | `computer_screenshot` (via MCP Synapse) |\n| Taper à (x,y) | `computer_command_queue {type:\"click\", payload:{x,y}}` |\n| Saisir du texte | `computer_command_queue {type:\"type\", payload:{text:\"...\"}}` |\n| Appuyer sur Home | `computer_command_queue {type:\"key\", payload:{keys:[\"Cmd\",\"Shift\",\"H\"]}}` |\n\n## Bonnes pratiques\n\n> [!TIP]\n> - **Stockez les coordonnées UI en mémoire** — l'UI change, mais le LLM peut réapprendre\n> - **Utilisez les labels d'accessibilité** — plus stables que les coordonnées\n> - **Stockez les données de test séparément** — utilisez des variables pour les noms d'utilisateur, mots de passe\n> - **Exécutez les tests dans un état propre** — réinitialisez Simulator entre les exécutions\n> - **Journalisez les captures d'écran pour les échecs** — utiles pour le débogage\n\n## Prochaines étapes\n\n- [Tests auto-réparables](/docs/guides/self-healing-tests)\n- [API Computer Control](/docs/api/computers)\n- [Bonnes pratiques mémoire](/docs/guides/memory-best-practices)\n","content_html":"<h1>Tests automatisés d&#39;applications iOS</h1>\n<p>Combinez le système de mémoire de Synapse avec l&#39;API Computer Control pour construire\ndes tests d&#39;applications iOS pilotés par LLM. Le LLM se souvient des scénarios de\ntest, apprend des échecs passés et s&#39;adapte aux changements d&#39;interface.</p>\n<h2>Architecture</h2>\n<pre><code class=\"hljs language-plaintext\">┌──────────────┐    commands    ┌──────────────┐    screenshots    ┌──────────────┐\n│  LLM Agent   │ ─────────────▶│  Synapse     │ ────────────────▶ │  iOS Sim     │\n│  (Claude)    │               │  Computer    │ ◀──────────────── │  (via agent) │\n└──────────────┘               │  Control     │    results        └──────────────┘\n       │                       └──────────────┘\n       │ store/recall\n       ▼\n┌──────────────┐\n│  Memories    │ (test scenarios, past failures, UI patterns)\n└──────────────┘</code></pre><h2>Prérequis</h2>\n<ul>\n<li>Compte Synapse + Mind Key</li>\n<li>Serveur MCP Synapse configuré dans Claude Desktop</li>\n<li>iOS Simulator avec <code>screen-remote-agent</code> installé</li>\n<li>Ordinateur enregistré dans Synapse (voir <a href=\"/docs/api/computers\">API Computer Control</a>)</li>\n</ul>\n<h2>Étape 1 : enregistrer l&#39;ordinateur Simulator</h2>\n<p>Sur le Mac exécutant iOS Simulator :</p>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-comment\"># Obtenir le code d&#x27;installation de Synapse</span>\ncurl -X POST https://synapse.schaefer.zone/computers/install-code \\\n  -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{&quot;computer_name&quot;:&quot;ios-sim&quot;}&#x27;</span>\n<span class=\"hljs-comment\"># → { &quot;install_code&quot;: &quot;ic_...&quot; }</span>\n\n<span class=\"hljs-comment\"># Exécuter screen-remote-agent sur le Mac</span>\n<span class=\"hljs-comment\"># (utilise le code d&#x27;installation pour s&#x27;enregistrer)</span></code></pre><h2>Étape 2 : stocker les scénarios de test en mémoire</h2>\n<p>Stockez les scénarios de test réutilisables en tant que mémoires :</p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import</span> requests\n\n<span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">store_test_scenario</span>(<span class=\"hljs-params\">name, steps, app</span>):\n    requests.post(<span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/memory&quot;</span>,\n        headers={<span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{MIND_KEY}</span>&quot;</span>},\n        json={\n            <span class=\"hljs-string\">&quot;category&quot;</span>: <span class=\"hljs-string\">&quot;skill&quot;</span>,\n            <span class=\"hljs-string\">&quot;key&quot;</span>: <span class=\"hljs-string\">f&quot;test_scenario_<span class=\"hljs-subst\">{name}</span>&quot;</span>,\n            <span class=\"hljs-string\">&quot;content&quot;</span>: <span class=\"hljs-string\">f&quot;App: <span class=\"hljs-subst\">{app}</span>\\nSteps:\\n&quot;</span> + <span class=\"hljs-string\">&quot;\\n&quot;</span>.join(steps),\n            <span class=\"hljs-string\">&quot;tags&quot;</span>: [<span class=\"hljs-string\">&quot;test&quot;</span>, <span class=\"hljs-string\">&quot;ios&quot;</span>, app],\n            <span class=\"hljs-string\">&quot;priority&quot;</span>: <span class=\"hljs-string\">&quot;high&quot;</span>\n        })\n\nstore_test_scenario(<span class=\"hljs-string\">&quot;login_flow&quot;</span>, [\n    <span class=\"hljs-string\">&quot;Launch app&quot;</span>,\n    <span class=\"hljs-string\">&quot;Tap email field&quot;</span>,\n    <span class=\"hljs-string\">&quot;Type test@example.com&quot;</span>,\n    <span class=\"hljs-string\">&quot;Tap password field&quot;</span>,\n    <span class=\"hljs-string\">&quot;Type password123&quot;</span>,\n    <span class=\"hljs-string\">&quot;Tap Login button&quot;</span>,\n    <span class=\"hljs-string\">&quot;Verify home screen appears&quot;</span>\n], <span class=\"hljs-string\">&quot;MyApp&quot;</span>)</code></pre><h2>Étape 3 : exécution de test pilotée par LLM</h2>\n<p>Dans Claude Desktop (avec MCP Synapse configuré) :</p>\n<pre><code class=\"hljs language-plaintext\">Run the login_flow test scenario on the iOS Simulator.\nTake a screenshot after each step and verify the expected UI.\nIf any step fails, store the failure as a memory so we can\navoid it next time.</code></pre><p>Claude va :</p>\n<ol>\n<li>Appeler <code>memory_search</code> pour trouver la mémoire <code>test_scenario_login_flow</code></li>\n<li>Appeler <code>computer_screenshot</code> pour voir l&#39;état actuel</li>\n<li>Exécuter chaque étape via <code>computer_command_queue</code> (clic, saisie)</li>\n<li>Vérifier les résultats via captures d&#39;écran</li>\n<li>Stocker tout échec en tant que mémoires <code>mistake</code></li>\n</ol>\n<h2>Étape 4 : tests auto-réparables</h2>\n<p>Quand un test échoue, stockez l&#39;échec et la récupération :</p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">store_test_failure</span>(<span class=\"hljs-params\">scenario, step, error, recovery</span>):\n    requests.post(<span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/memory&quot;</span>,\n        headers={<span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{MIND_KEY}</span>&quot;</span>},\n        json={\n            <span class=\"hljs-string\">&quot;category&quot;</span>: <span class=\"hljs-string\">&quot;mistake&quot;</span>,\n            <span class=\"hljs-string\">&quot;key&quot;</span>: <span class=\"hljs-string\">f&quot;failure_<span class=\"hljs-subst\">{scenario}</span>_<span class=\"hljs-subst\">{step}</span>&quot;</span>,\n            <span class=\"hljs-string\">&quot;content&quot;</span>: <span class=\"hljs-string\">f&quot;Scenario: <span class=\"hljs-subst\">{scenario}</span>\\nStep: <span class=\"hljs-subst\">{step}</span>\\nError: <span class=\"hljs-subst\">{error}</span>\\nRecovery: <span class=\"hljs-subst\">{recovery}</span>&quot;</span>,\n            <span class=\"hljs-string\">&quot;tags&quot;</span>: [<span class=\"hljs-string\">&quot;test&quot;</span>, <span class=\"hljs-string\">&quot;failure&quot;</span>, <span class=\"hljs-string\">&quot;ios&quot;</span>, scenario],\n            <span class=\"hljs-string\">&quot;priority&quot;</span>: <span class=\"hljs-string\">&quot;high&quot;</span>\n        })\n\n<span class=\"hljs-comment\"># Exemple</span>\nstore_test_failure(<span class=\"hljs-string\">&quot;login_flow&quot;</span>, <span class=\"hljs-string\">&quot;tap_login&quot;</span>,\n    <span class=\"hljs-string\">&quot;Login button not found at expected coordinates&quot;</span>,\n    <span class=\"hljs-string\">&quot;Button moved due to new logo. Search by accessibility label instead.&quot;</span>)</code></pre><p>La prochaine fois que le LLM exécute le test, il rappelle l&#39;échec et applique la\nrécupération automatiquement.</p>\n<h2>Étape 5 : suivi des résultats de test</h2>\n<p>Suivez les exécutions de test en tant que tâches :</p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">track_test_run</span>(<span class=\"hljs-params\">scenario, status, duration</span>):\n    requests.post(<span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/mind/task&quot;</span>,\n        headers={<span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{MIND_KEY}</span>&quot;</span>,\n                 <span class=\"hljs-string\">&quot;Content-Type&quot;</span>: <span class=\"hljs-string\">&quot;application/json&quot;</span>},\n        json={\n            <span class=\"hljs-string\">&quot;title&quot;</span>: <span class=\"hljs-string\">f&quot;Test: <span class=\"hljs-subst\">{scenario}</span>&quot;</span>,\n            <span class=\"hljs-string\">&quot;description&quot;</span>: <span class=\"hljs-string\">f&quot;Status: <span class=\"hljs-subst\">{status}</span>, Duration: <span class=\"hljs-subst\">{duration}</span>s&quot;</span>,\n            <span class=\"hljs-string\">&quot;priority&quot;</span>: <span class=\"hljs-string\">&quot;normal&quot;</span>\n        })</code></pre><h2>Commandes courantes</h2>\n<table>\n<thead>\n<tr>\n<th>Action</th>\n<th>Commande</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Lancer Simulator</td>\n<td><code>xcrun simctl launch booted com.example.app</code></td>\n</tr>\n<tr>\n<td>Capture d&#39;écran</td>\n<td><code>computer_screenshot</code> (via MCP Synapse)</td>\n</tr>\n<tr>\n<td>Taper à (x,y)</td>\n<td><code>computer_command_queue {type:&quot;click&quot;, payload:{x,y}}</code></td>\n</tr>\n<tr>\n<td>Saisir du texte</td>\n<td><code>computer_command_queue {type:&quot;type&quot;, payload:{text:&quot;...&quot;}}</code></td>\n</tr>\n<tr>\n<td>Appuyer sur Home</td>\n<td><code>computer_command_queue {type:&quot;key&quot;, payload:{keys:[&quot;Cmd&quot;,&quot;Shift&quot;,&quot;H&quot;]}}</code></td>\n</tr>\n</tbody></table>\n<h2>Bonnes pratiques</h2>\n<div class=\"callout callout-ok\"></div><h2>Prochaines étapes</h2>\n<ul>\n<li><a href=\"/docs/guides/self-healing-tests\">Tests auto-réparables</a></li>\n<li><a href=\"/docs/api/computers\">API Computer Control</a></li>\n<li><a href=\"/docs/guides/memory-best-practices\">Bonnes pratiques mémoire</a></li>\n</ul>\n","urls":{"html":"/docs/guides/automated-testing-ios","text":"/docs/guides/automated-testing-ios?format=text","json":"/docs/guides/automated-testing-ios?format=json","llm":"/docs/guides/automated-testing-ios?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}