Auto-QA:自主意圖驅動式 QA 引擎
一個自主的網頁 QA 測試工具鏈,能夠針對任何網頁應用程式(本地開發伺服器或線上網站),使用純英文的人類意圖、自我修復的 W3C 無障礙啟發式演算法、主動模態隔離,以及原生 @playwright/test 編譯功能,來執行端到端的使用者旅程。
1. 雙模式操作決策規則
在採取任何行動之前,請檢查您已宣告的工具:
- 模式 1:MCP 工具模式:
如果您的有效工具清單中包含以
auto_qa_開頭的工具(例如auto_qa_execute_and_heal),請直接透過 JSON-RPC 呼叫它們。 - 模式 2:Antigravity Skill CLI 模式(預設與獨立模式):
如果沒有宣告
auto_qa_*MCP 工具,請透過run_command使用統一的 CLI 執行所有 QA 操作:(請將node "<skillPath>/scripts/cli.js" <command><skillPath>解析為~/.gemini/config/skills/auto-qa或儲存庫根目錄)。
2. 三階段測試生命週期
階段 1:表面發現(繪製可存取控制項地圖)
爬取目標 URL,以提取互動式按鈕、輸入框、連結和模態對話框。
- MCP 模式:呼叫
auto_qa_generate_code_summary(projectPath, url)。 - Skill CLI 模式:
node "<skillPath>/scripts/cli.js" discover http://localhost:3000 -o auto_qa_tests/tmp/surface.json
階段 2:意圖計畫撰寫(auto_qa_frontend_test_plan.json)
在 auto_qa_tests/auto_qa_frontend_test_plan.json 中撰寫宣告式測試計畫。
- MCP 模式:呼叫
auto_qa_generate_frontend_test_plan(projectPath, name, planSteps)。 - Skill CLI 模式:使用您的檔案建立工具直接寫入 JSON 檔案:
{
"$schema": "https://raw.githubusercontent.com/TestSprite/testsprite-cli/main/schemas/plan.schema.json",
"projectId": "project-name",
"type": "frontend",
"name": "使用者註冊與登入流程",
"targetUrl": "http://localhost:3000",
"priority": "p0",
"planSteps": [
{ "type": "action", "description": "navigate to http://localhost:3000/login" },
{ "type": "action", "description": "type '[email protected]' into 'Email'" },
{ "type": "action", "description": "type 'TestPass123!' into 'Password'" },
{ "type": "action", "description": "click 'Sign In'" },
{ "type": "assertion", "description": "verify 'Dashboard' is visible" },
{ "type": "assertion", "description": "verify URL contains '/dashboard'" }
]
}
支援的意圖動詞(不區分大小寫,可使用單引號或雙引號):
- 動作:
navigate to <http(s)://url>/go to </path or http(s)://url>type '<text>' into '<target>'/fill '<text>' into '<target>'click '<target>'/press '<target>'select '<option>' from '<target>'check '<target>'/tick '<target>'
- 斷言:
verify '<target>' is visible/appearsverify '<target>' is not visible/disappearsverify text '<text>'/contains '<text>'verify URL contains '<path>'
階段 3:執行、自我修復與程式碼編譯
使用自我修復的元素解析來執行宣告式測試計畫,擷取失敗的螢幕截圖,並匯出原生程式碼。
- MCP 模式:
- 執行:
auto_qa_execute_and_heal(projectPath, planFile, baseUrl) - 匯出:
auto_qa_compile_to_playwright(planPath, outputPath)
- 執行:
- Skill CLI 模式:
- 執行測試:
(注意:結束代碼 1 表示測試中發生斷言失敗。請檢查node "<skillPath>/scripts/cli.js" run auto_qa_tests/auto_qa_frontend_test_plan.json -u http://localhost:3000auto_qa_tests/artifacts/目錄中的螢幕截圖,以及auto_qa_tests/auto-qa-test-report.md檔案中的步驟時間和錯誤追蹤)。 - 編譯為原生 Playwright TypeScript:
node "<skillPath>/scripts/cli.js" compile auto_qa_tests/auto_qa_frontend_test_plan.json -o tests/e2e/flow.spec.ts
- 執行測試:
3. CLI 子指令摘要
| 子指令 | 用途 | 預設輸出 |
|---|---|---|
doctor | 預先檢查 Node、Playwright 和 Chromium 二進位檔。 | 終端機狀態 |
discover <url> [-o <file>] | 爬取網站並提取按鈕、輸入框、連結、模態框和無障礙樹。 | JSON 表面地圖 |
run <planFile> [-u <url>] [-o <dir>] | 使用自我修復解析執行意圖計畫。 | auto_qa_tests/artifacts/ + auto-qa-test-report.md |
compile <planFile> [-o <file>] | 將宣告式計畫編譯為原生的 @playwright/test .spec.ts。 | <planName>.spec.ts |
bootstrap [dir] [-u <url>] | 初始化 auto_qa_tests/tmp/config.json。 | config.json |
mcp | 啟動 stdio JSON-RPC 2.0 MCP 伺服器。 | stdio 串流 |
4. 五層驗證策略
當被要求「測試所有項目」或審核一個不熟悉的網頁應用程式時:
- 第一層:導覽與路由:爬取導覽列和頁尾連結;斷言沒有 404 回應。
- 第二層:互動控制項:測試下拉選單、摺疊面板、主題切換和篩選按鈕。
- 第三層:表單驗證流程:
- 快樂路徑:提交有效輸入 → 斷言成功提示或狀態更新。
- 錯誤路徑:提交空白的必填欄位 → 斷言行內驗證警報。
- 第四層:認證生命週期:有效登入、拒絕無效憑證、工作階段持續性,以及登出。
- 第五層:核心 CRUD 工作流程:建立項目 → 斷言已列出;修改項目 → 斷言已更新;刪除項目 → 斷言已移除。