Auto-QA:自主意图驱动的QA引擎
一个自主的Web QA测试工具链,能够根据纯英文的人类意图,针对任何Web应用(本地开发服务器或在线网站)执行端到端的用户旅程测试。它具备自愈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 surface map |
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 stream |
4. 五层验证策略
当被要求“测试所有内容”或审计一个不熟悉的Web应用时,请遵循以下策略:
- 第一层:导航与路由:爬取导航栏和页脚链接;断言无404响应。
- 第二层:交互控件:测试下拉菜单、折叠面板、主题切换和筛选按钮。
- 第三层:表单验证漏斗:
- 快乐路径:提交有效输入 → 断言成功提示或状态更新。
- 错误路径:提交空必填字段 → 断言内联验证警报。
- 第四层:认证生命周期:有效登录、无效凭证拒绝、会话持久化及登出。
- 第五层:核心CRUD流程:创建条目 → 断言已列出;修改条目 → 断言已更新;删除条目 → 断言已移除。