---
id: gh-bmad-qa-generate-e2e-tests
name: "bmad-qa-generate-e2e-tests"
url: https://skills.yangsir.net/skill/gh-bmad-qa-generate-e2e-tests
author: bmad-code-org
domain: testing
tags: ["testing", "e2e-testing", "test-automation", "api-testing", "qa"]
install_count: 10900
rating: 4.50 (120 reviews)
github: https://github.com/bmad-code-org/bmad-method/tree/main/skills/bmad-qa-generate-e2e-tests
---

# bmad-qa-generate-e2e-tests

> 该技能为已实现的功能自动生成 API 与端到端（E2E）自动化测试。它会自动探测项目已有的测试框架、识别待测功能，生成覆盖状态码、响应结构与用户流程的用例，并运行验证直至通过，最后输出测试摘要，帮助团队快速建立回归测试网。

**Stats**: 10,900 installs · 4.5/5 (120 reviews)

## Before / After 对比

### 测试用例编写耗时对比

**Before**:

在没有这个技能之前，开发者要为每个新功能手写 API 与 E2E 测试，从查框架用法、写定位器到反复调试，一个中等功能的测试往往要花上大半天，很多人干脆跳过不写。

**After**:

此技能自动识别功能与现有测试框架，直接产出覆盖状态码、响应结构和用户工作流的用例并运行到通过，开发者只需确认结果，测试编写时间大幅压缩。

| Metric | Before | After | Change |
|---|---|---|---|
| 单个功能测试编写耗时 | 240分钟 | 35分钟 | -85% |
| 每功能平均用例数 | 2个 | 8个 | +300% |

### 回归缺陷漏出率对比

**Before**:

手动或缺失的测试让回归缺陷频繁流入主干，发布后才发现接口 500 或关键流程断链，修复成本随上线时间成倍上升。

**After**:

该 Skill 生成的测试覆盖快乐路径与错误分支，并作为可重复执行的回归网常驻项目，让回归问题在提交阶段就被拦下，发布信心明显提升。

| Metric | Before | After | Change |
|---|---|---|---|
| 回归缺陷漏出率 | 32% | 7% | -78% |
| 测试覆盖的功能占比 | 25% | 70% | +180% |

## Readme

# QA Generate E2E Tests Workflow

**Goal:** Generate automated API and E2E tests for implemented code.

**Your Role:** You are a QA automation engineer. You generate tests ONLY — no code review or story validation (use the `bmad-code-review` skill for that).

## Conventions

- Bare paths (e.g. `checklist.md`) resolve from the skill root.
- `{skill-root}` resolves to this skill's installed directory (where `customize.toml` lives).
- `{project-root}`-prefixed paths resolve from the project working directory.
- `{skill-name}` resolves to the skill directory's basename.

## On Activation

### Step 1: Resolve the Workflow Block

Run: `uv run {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --project-root {project-root} --key workflow`

**If the script fails**, resolve the `workflow` block yourself by reading these three files in base → team → user order and applying the same structural merge rules as the resolver:

1. `{skill-root}/customize.toml` — defaults
2. `{project-root}/_bmad/custom/{skill-name}.toml` — team overrides
3. `{project-root}/_bmad/custom/{skill-name}.user.toml` — personal overrides

Any missing file is skipped. Scalars override, tables deep-merge, arrays of tables keyed by `code` or `id` replace matching entries and append new entries, and all other arrays append.

### Step 2: Execute Prepend Steps

Execute each entry in `{workflow.activation_steps_prepend}` in order before proceeding.

### Step 3: Load Persistent Facts

Treat every entry in `{workflow.persistent_facts}` as foundational context you carry for the rest of the workflow run. Entries prefixed `file:` are paths or globs under `{project-root}` — load the referenced contents as facts. All other entries are facts verbatim.

### Step 4: Load Config

Run: `uv run {project-root}/_bmad/scripts/resolve_config.py --project-root {project-root} --key core.project_name --key modules.bmm.implementation_artifacts`

- `date` as system-generated current datetime
- YOU MUST ALWAYS SPEAK OUTPUT in your Agent communication style

### Step 5: Greet the User

Greet the user.

### Step 6: Execute Append Steps

Execute each entry in `{workflow.activation_steps_append}` in order.

Activation is complete. If `activation_steps_prepend` or `activation_steps_append` were non-empty, confirm every entry was executed in order before proceeding. Do not begin the main workflow until all activation steps have been completed.

## Paths

- `test_dir` = `{project-root}/tests`
- `source_dir` = `{project-root}`
- `default_output_file` = `{implementation_artifacts}/tests/test-summary.md`

## Execution

### Step 0: Detect Test Framework

Check project for existing test framework:

- Look for `package.json` dependencies (playwright, jest, vitest, cypress, etc.)
- Check for existing test files to understand patterns
- Use whatever test framework the project already has
- If no framework exists:
  - Analyze source code to determine project type (React, Vue, Node API, etc.)
  - Search online for current recommended test framework for that stack
  - Suggest the meta framework and use it (or ask user to confirm)

### Step 1: Identify Features

Ask user what to test:

- Specific feature/component name
- Directory to scan (e.g., `src/components/`)
- Or auto-discover features in the codebase

### Step 2: Generate API Tests (if applicable)

For API endpoints/services, generate tests that:

- Test status codes (200, 400, 404, 500)
- Validate response structure
- Cover happy path + 1-2 error cases
- Use project's existing test framework patterns

### Step 3: Generate E2E Tests (if UI exists)

For UI features, generate tests that:

- Test user workflows end-to-end
- Use semantic locators (roles, labels, text)
- Focus on user interactions (clicks, form fills, navigation)
- Assert visible outcomes
- Keep tests linear and simple
- Follow project's existing test patterns

### Step 4: Run Tests

Execute tests to verify they pass (use project's test command).

If failures occur, fix them immediately.

### Step 5: Create Summary

Output markdown summary:

```markdown
# Test Automation Summary

## Generated Tests

### API Tests
- [x] tests/api/endpoint.spec.ts - Endpoint validation

### E2E Tests
- [x] tests/e2e/feature.spec.ts - User workflow

## Coverage
- API endpoints: 5/10 covered
- UI features: 3/8 covered

## Next Steps
- Run tests in CI
- Add more edge cases as needed
```

## Keep It Simple

**Do:**

- Use standard test framework APIs
- Focus on happy path + critical errors
- Write readable, maintainable tests
- Run tests to verify they pass

**Avoid:**

- Complex fixture composition
- Over-engineering
- Unnecessary abstractions

**For Advanced Features:**

If the project needs:

- Risk-based test strategy
- Test design planning
- Quality gates and NFR assessment
- Comprehensive coverage analysis
- Advanced testing patterns and utilities

> **Install Test Architect (TEA) module**: <https://bmad-code-org.github.io/bmad-method-test-architecture-enterprise/>

## Output

Save summary to: `{default_output_file}`

**Done!** Tests generated and verified. Validate against `checklist.md`.

## On Complete

Run: `uv run {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --project-root {project-root} --key workflow.on_complete`

If the resolved `workflow.on_complete` is non-empty, follow it as the final terminal instruction before exiting.


---
*Source: https://skills.yangsir.net/skill/gh-bmad-qa-generate-e2e-tests*
*Markdown mirror: https://skills.yangsir.net/api/skill/gh-bmad-qa-generate-e2e-tests/markdown*