/test-execution
测试执行方法,包含测试框架检测、覆盖率门禁、多框架结果解析、失败分级、增量测试选择、并行执行策略
Claude Code
$ npx -y skills add echoVic/boss-skill --skill test-execution --agent claude-code
Codex
$ npx skills add echoVic/boss-skill --skill test-execution -a codex -y
Cursor
$ npx skills add echoVic/boss-skill --skill test-execution -a cursor -y
Gemini CLI
$ npx skills add echoVic/boss-skill --skill test-execution -a gemini-cli -y
GitHub Copilot
$ npx skills add echoVic/boss-skill --skill test-execution -a github-copilot -y
OpenCode
$ npx skills add echoVic/boss-skill --skill test-execution -a opencode -y
Windsurf
$ npx skills add echoVic/boss-skill --skill test-execution -a windsurf -y
SKILL.md
test-execution.SKILL.mdname: qa/test-execution
description: 测试执行方法,包含测试框架检测、覆盖率门禁、多框架结果解析、失败分级、增量测试选择、并行执行策略
version: 2.0.0
agent: qa
type: methodology
user-invocable: false
agent-invocable: true
dependencies:
- shared/tech-stack-detection
triggers:
- 需要执行测试时
- 需要验证测试覆盖率时
- 需要解析测试结果时
metadata:
internal: true
测试执行方法
强制要求:真实执行测试
**你必须真正执行测试,禁止生成 Mock 数据!**
测试执行流程
1. **检测项目类型和测试框架** 2. **执行单元测试**(含覆盖率) 3. **执行集成测试** 4. **执行接口测试** 5. **执行 E2E 测试** 6. **解析测试输出**(总数、通过数、失败数、覆盖率) 7. **失败分级与处理**
测试框架检测
JavaScript/TypeScript
| 框架 | 检测标志 | 配置文件 | | ---------- | --------------------------------------- | ----------------------------------- | | Jest | `"jest"` in devDependencies | `jest.config.js` / `jest.config.ts` | | Vitest | `"vitest"` in devDependencies | `vitest.config.ts` | | Playwright | `"@playwright/test"` in devDependencies | `playwright.config.ts` | | Cypress | `"cypress"` in devDependencies | `cypress.config.ts` |
Python
| 框架 | 检测标志 | 配置文件 | | -------- | -------------------------- | ------------------------------- | | pytest | `"pytest"` in dependencies | `pytest.ini` / `pyproject.toml` | | unittest | 内置 | - |
Go
- `*_test.go` 文件存在 → 使用 `go test`
- 集成测试通常用 build tag 隔离:`//go:build integration`
Java
| 框架 | 检测标志 | | ------- | ---------------------------- | | JUnit 5 | `pom.xml` 含 `junit-jupiter` | | TestNG | `pom.xml` 含 `testng` |
测试命令矩阵
| 语言 | 单元测试 | 集成测试 | 接口测试 | E2E 测试 | | ------- | ----------------------------- | ---------------------------------- | -------------------------- | --------------------- | | Node.js | `npx vitest run` / `npx jest` | `npx vitest run tests/integration` | `npx vitest run tests/api` | `npx playwright test` | | Python | `pytest tests/unit` | `pytest tests/integration` | `pytest tests/api` | `pytest tests/e2e` | | Go | `go test ./internal/...` | `go test -tags=integration ./...` | `go test ./tests/api/...` | - | | Java | `mvn test` | `mvn verify` | `mvn verify -Papi-test` | - |
> 接口测试方法论见 `Skill(skill: "qa/api-testing")`,集成测试方法论见 `Skill(skill: "qa/integration-testing")`。
覆盖率度量与门禁
覆盖率采集
# Vitest
npx vitest run --coverage --reporter=json
# 输出 coverage/coverage-summary.json
# Jest
npx jest --coverage --coverageReporters=json-summary
# 输出 coverage/coverage-summary.json
# Python (pytest-cov)
pytest --cov=src --cov-report=json
# 输出 coverage.json
# Go
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
覆盖率报告解析
`coverage-summary.json` 结构:
{
"total": {
"lines": { "total": 100, "covered": 85, "pct": 85 },
"statements": { "total": 120, "covered": 100, "pct": 83.3 },
"functions": { "total": 40, "covered": 36, "pct": 90 },
"branches": { "total": 30, "covered": 22, "pct": 73.3 }
}
}覆盖率门禁
| 指标 | 门槛 | 未达标处理 | | -------------- | ----- | ---------------------------------- | | 行覆盖率 | ≥ 80% | 列出未覆盖行,报 `REVISION_NEEDED` | | 语句覆盖率 | ≥ 80% | 同上 | | 函数覆盖率 | ≥ 80% | 同上 | | 分支覆盖率 | ≥ 75% | 列出未覆盖分支 | | 变更文件覆盖率 | ≥ 80% | 重点检查本次变更文件 |
**覆盖率检查脚本**(Node.js):
# 检查覆盖率是否达标
node -e "
const cov = require('./coverage/coverage-summary.json').total;
const thresholds = { lines: 80, statements: 80, functions: 80, branches: 75 };
let failed = false;
for (const [key, min] of Object.entries(thresholds)) {
const pct = cov[key].pct;
if (pct < min) {
console.log(\`❌ \${key}: \${pct}% < \${min}%\`);
failed = true;
} else {
console.log(\`✅ \${key}: \${pct}%\`);
}
}
process.exit(failed ? 1 : 0);
"测试结果解析
Jest / Vitest JSON 输出
npx jest --json --outputFile=test-results.json
# 或
npx vitest run --reporter=json --outputFile=test-results.json
解析关键字段:
{
"numTotalTests": 50,
"numPassedTests": 48,
"numFailedTests": 2,
"numPendingTests": 0,
"success": false,
"testResults": [
{
"name": "tests/api/users.test.ts",
"status": "failed",
"assertionResults": [
{
"title": "creates user with valid data",
"status": "passed",
"duration": 15
},
{
"title": "rejects empty name with 400",
"status": "failed",
"failureMessages": ["Expected 400, received 201"]
}
]
}
]
}pytest JSON 输出
pytest tests/ -v --json-report --json-report-file=test-results.json
解析:
{
"summary": {
"total": 30,
"passed": 28,
"failed": 2,
"skipped": 0,
"duration": 2.5
}
}Go test 输出
go test ./... -json > test-results.json
解析(每行一个 JSON):
# 统计通过/失败
go test ./... -v 2>&1 | grep -E "^(=== RUN|--- (PASS|FAIL|SKIP))" | \
awk '/PASS/{p++} /FAIL/{f++} /SKIP/{s++} END{print "passed:"p" failed:"f" skipped:"s}'Playwright JSON 输出
| 字段 | 说明 | | ------------------ | ------------------ | | `stats.expected` | 通过的测试数 | | `stats.unexpected` | 失败的测试数 | | `stats.flaky` | 重试后通过的测试数 | | `stats.skipped` | 跳过的测试数 |
失败分级与处理
失败分级
| 级别 | 判定标准 | 处理方式 | | ------------ | ---------------------------------- | ------------------ | | **Blocker** | 核心功能不可用、数据丢失、安全漏洞 | 立即修复,阻止发布 | | **Critical** | 主要功能异常、数据不一致 | 必须修复,阻塞发布 | | **Major** | 次要功能异常、有 workaround | 修复后发布 | | **Minor** | UI 展示问题、文案错误 | 可
Read more
name: qa/test-execution description: 测试执行方法,包含测试框架检测、覆盖率门禁、多框架结果解析、失败分级、增量测试选择、并行执行策略 version: 2.0.0 agent: qa type: methodology user-invocable: false agent-invocable: true dependencies: - shared/tech-stack-detection triggers: - 需要执行测试时 - 需要验证测试覆盖率时 - 需要解析测试结果时 metadata: internal: true
测试执行方法
强制要求:真实执行测试
**你必须真正执行测试,禁止生成 Mock 数据!**
测试执行流程
1. **检测项目类型和测试框架** 2. **执行单元测试**(含覆盖率) 3. **执行集成测试** 4. **执行接口测试** 5. **执行 E2E 测试** 6. **解析测试输出**(总数、通过数、失败数、覆盖率) 7. **失败分级与处理**
测试框架检测
JavaScript/TypeScript
| 框架 | 检测标志 | 配置文件 | | ---------- | --------------------------------------- | ----------------------------------- | | Jest | `"jest"` in devDependencies | `jest.config.js` / `jest.config.ts` | | Vitest | `"vitest"` in devDependencies | `vitest.config.ts` | | Playwright | `"@playwright/test"` in devDependencies | `playwright.config.ts` | | Cypress | `"cypress"` in devDependencies | `cypress.config.ts` |
Python
| 框架 | 检测标志 | 配置文件 | | -------- | -------------------------- | ------------------------------- | | pytest | `"pytest"` in dependencies | `pytest.ini` / `pyproject.toml` | | unittest | 内置 | - |
Go
- `*_test.go` 文件存在 → 使用 `go test`
- 集成测试通常用 build tag 隔离:`//go:build integration`
Java
| 框架 | 检测标志 | | ------- | ---------------------------- | | JUnit 5 | `pom.xml` 含 `junit-jupiter` | | TestNG | `pom.xml` 含 `testng` |
测试命令矩阵
| 语言 | 单元测试 | 集成测试 | 接口测试 | E2E 测试 | | ------- | ----------------------------- | ---------------------------------- | -------------------------- | --------------------- | | Node.js | `npx vitest run` / `npx jest` | `npx vitest run tests/integration` | `npx vitest run tests/api` | `npx playwright test` | | Python | `pytest tests/unit` | `pytest tests/integration` | `pytest tests/api` | `pytest tests/e2e` | | Go | `go test ./internal/...` | `go test -tags=integration ./...` | `go test ./tests/api/...` | - | | Java | `mvn test` | `mvn verify` | `mvn verify -Papi-test` | - |
> 接口测试方法论见 `Skill(skill: "qa/api-testing")`,集成测试方法论见 `Skill(skill: "qa/integration-testing")`。
覆盖率度量与门禁
覆盖率采集
# Vitest npx vitest run --coverage --reporter=json # 输出 coverage/coverage-summary.json # Jest npx jest --coverage --coverageReporters=json-summary # 输出 coverage/coverage-summary.json # Python (pytest-cov) pytest --cov=src --cov-report=json # 输出 coverage.json # Go go test -coverprofile=coverage.out ./... go tool cover -func=coverage.out
覆盖率报告解析
`coverage-summary.json` 结构:
{
"total": {
"lines": { "total": 100, "covered": 85, "pct": 85 },
"statements": { "total": 120, "covered": 100, "pct": 83.3 },
"functions": { "total": 40, "covered": 36, "pct": 90 },
"branches": { "total": 30, "covered": 22, "pct": 73.3 }
}
}覆盖率门禁
| 指标 | 门槛 | 未达标处理 | | -------------- | ----- | ---------------------------------- | | 行覆盖率 | ≥ 80% | 列出未覆盖行,报 `REVISION_NEEDED` | | 语句覆盖率 | ≥ 80% | 同上 | | 函数覆盖率 | ≥ 80% | 同上 | | 分支覆盖率 | ≥ 75% | 列出未覆盖分支 | | 变更文件覆盖率 | ≥ 80% | 重点检查本次变更文件 |
**覆盖率检查脚本**(Node.js):
# 检查覆盖率是否达标
node -e "
const cov = require('./coverage/coverage-summary.json').total;
const thresholds = { lines: 80, statements: 80, functions: 80, branches: 75 };
let failed = false;
for (const [key, min] of Object.entries(thresholds)) {
const pct = cov[key].pct;
if (pct < min) {
console.log(\`❌ \${key}: \${pct}% < \${min}%\`);
failed = true;
} else {
console.log(\`✅ \${key}: \${pct}%\`);
}
}
process.exit(failed ? 1 : 0);
"测试结果解析
Jest / Vitest JSON 输出
npx jest --json --outputFile=test-results.json # 或 npx vitest run --reporter=json --outputFile=test-results.json
解析关键字段:
{
"numTotalTests": 50,
"numPassedTests": 48,
"numFailedTests": 2,
"numPendingTests": 0,
"success": false,
"testResults": [
{
"name": "tests/api/users.test.ts",
"status": "failed",
"assertionResults": [
{
"title": "creates user with valid data",
"status": "passed",
"duration": 15
},
{
"title": "rejects empty name with 400",
"status": "failed",
"failureMessages": ["Expected 400, received 201"]
}
]
}
]
}pytest JSON 输出
pytest tests/ -v --json-report --json-report-file=test-results.json
解析:
{
"summary": {
"total": 30,
"passed": 28,
"failed": 2,
"skipped": 0,
"duration": 2.5
}
}Go test 输出
go test ./... -json > test-results.json
解析(每行一个 JSON):
# 统计通过/失败
go test ./... -v 2>&1 | grep -E "^(=== RUN|--- (PASS|FAIL|SKIP))" | \
awk '/PASS/{p++} /FAIL/{f++} /SKIP/{s++} END{print "passed:"p" failed:"f" skipped:"s}'Playwright JSON 输出
| 字段 | 说明 | | ------------------ | ------------------ | | `stats.expected` | 通过的测试数 | | `stats.unexpected` | 失败的测试数 | | `stats.flaky` | 重试后通过的测试数 | | `stats.skipped` | 跳过的测试数 |
失败分级与处理
失败分级
| 级别 | 判定标准 | 处理方式 | | ------------ | ---------------------------------- | ------------------ | | **Blocker** | 核心功能不可用、数据丢失、安全漏洞 | 立即修复,阻止发布 | | **Critical** | 主要功能异常、数据不一致 | 必须修复,阻塞发布 | | **Major** | 次要功能异常、有 workaround | 修复后发布 | | **Minor** | UI 展示问题、文案错误 | 可
Languages / 语言 / 言語 / 언어 / Idiomas / Langues: English · 中文 · 日本語 · 한국어 · Español · Français · Português This project is part of the AtomGit G-Star Incubation Program.
Other skills on boss.
More skills from other plugins.
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
ask-matt
Ask which skill or flow fits your situation. A router over the skills in this repo.
Questions about test-execution.
- Which coding agents can use test-execution?
- test-execution installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.

