coverage
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAnalyze Test Coverage Gaps
分析测试覆盖率缺口
Map all testable surfaces in the application and identify what's tested vs. what's missing.
梳理应用中所有可测试的模块,区分已测试内容与缺失的测试部分。
Steps
步骤
1. Map Application Surface
1. 梳理应用模块
Use the subagent to catalog:
ExploreRoutes/Pages:
- Scan route definitions (Next.js , React Router config, Vue Router, etc.)
app/ - List all user-facing pages with their paths
Components:
- Identify interactive components (forms, modals, dropdowns, tables)
- Note components with complex state logic
API Endpoints:
- Scan API route files or backend controllers
- List all endpoints with their methods
User Flows:
- Identify critical paths: auth, checkout, onboarding, core features
- Map multi-step workflows
使用子代理来分类整理:
Explore路由/页面:
- 扫描路由定义(Next.js 、React Router 配置、Vue Router 等)
app/ - 列出所有面向用户的页面及其路径
组件:
- 识别交互式组件(表单、模态框、下拉菜单、表格)
- 标记包含复杂状态逻辑的组件
API 端点:
- 扫描 API 路由文件或后端控制器
- 列出所有端点及其请求方法
用户流程:
- 识别关键路径:认证、结账、新用户引导、核心功能
- 梳理多步骤工作流
2. Map Existing Tests
2. 梳理现有测试用例
Scan all / files:
*.spec.ts*.spec.js- Extract which pages/routes are covered (by calls)
page.goto() - Extract which components are tested (by locator usage)
- Extract which API endpoints are mocked or hit
- Count tests per area
扫描所有 / 文件:
*.spec.ts*.spec.js- 提取已覆盖的页面/路由(通过调用判断)
page.goto() - 提取已测试的组件(通过定位器使用情况判断)
- 提取已模拟或调用的 API 端点
- 统计各区域的测试用例数量
3. Generate Coverage Matrix
3. 生成覆盖率矩阵
undefinedundefinedCoverage Matrix
Coverage Matrix
| Area | Route | Tests | Status |
|---|---|---|---|
| Auth | /login | 5 | ✅ Covered |
| Auth | /register | 0 | ❌ Missing |
| Auth | /forgot-password | 0 | ❌ Missing |
| Dashboard | /dashboard | 3 | ⚠️ Partial (no error states) |
| Settings | /settings | 0 | ❌ Missing |
| Checkout | /checkout | 8 | ✅ Covered |
undefined| Area | Route | Tests | Status |
|---|---|---|---|
| Auth | /login | 5 | ✅ Covered |
| Auth | /register | 0 | ❌ Missing |
| Auth | /forgot-password | 0 | ❌ Missing |
| Dashboard | /dashboard | 3 | ⚠️ Partial (no error states) |
| Settings | /settings | 0 | ❌ Missing |
| Checkout | /checkout | 8 | ✅ Covered |
undefined4. Prioritize Gaps
4. 优先级排序缺口
Rank uncovered areas by business impact:
- Critical — auth, payment, core features → test first
- High — user-facing CRUD, search, navigation
- Medium — settings, preferences, edge cases
- Low — static pages, about, terms
根据业务影响对未覆盖区域排序:
- 关键 — 认证、支付、核心功能 → 优先测试
- 高优先级 — 面向用户的增删改查、搜索、导航
- 中优先级 — 设置、偏好、边缘场景
- 低优先级 — 静态页面、关于页、条款页
5. Suggest Test Plan
5. 建议测试计划
For each gap, recommend:
- Number of tests needed
- Which template from to use
templates/ - Estimated effort (quick/medium/complex)
undefined针对每个缺口,推荐:
- 所需测试用例数量
- 使用中的哪个模板
templates/ - 预估工作量(快速/中等/复杂)
undefinedRecommended Test Plan
Recommended Test Plan
Priority 1: Critical
Priority 1: Critical
- /register (4 tests) — use auth/registration template — quick
- /forgot-password (3 tests) — use auth/password-reset template — quick
- /register (4 tests) — use auth/registration template — quick
- /forgot-password (3 tests) — use auth/password-reset template — quick
Priority 2: High
Priority 2: High
- /settings (4 tests) — use settings/ templates — medium
- Dashboard error states (2 tests) — use dashboard/data-loading template — quick
undefined- /settings (4 tests) — use settings/ templates — medium
- Dashboard error states (2 tests) — use dashboard/data-loading template — quick
undefined6. Auto-Generate (Optional)
6. 自动生成(可选)
Ask user: "Generate tests for the top N gaps? [Yes/No/Pick specific]"
If yes, invoke for each gap with the recommended template.
/pw:generate询问用户:“是否为前N个缺口生成测试用例?[是/否/选择特定缺口]”
如果用户同意,为每个缺口调用并使用推荐的模板。
/pw:generateOutput
输出
- Coverage matrix (table format)
- Coverage percentage estimate
- Prioritized gap list with effort estimates
- Option to auto-generate missing tests
- 覆盖率矩阵(表格格式)
- 覆盖率预估百分比
- 带工作量预估的优先级缺口列表
- 自动生成缺失测试用例的选项