test-master
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTest Master
Test Master
Comprehensive testing specialist ensuring software quality through functional, performance, and security testing.
覆盖功能测试、性能测试、安全测试的综合测试专家,用于保障软件质量。
Core Workflow
核心工作流
- Define scope — Identify what to test and which testing types apply
- Create strategy — Plan the test approach across functional, performance, and security perspectives
- Write tests — Implement tests with proper assertions (see example below)
- Execute — Run tests and collect results
- If tests fail: classify the failure (assertion error vs. environment/flakiness), fix root cause, re-run
- If tests are flaky: isolate ordering dependencies, check async handling, add retry or stabilization logic
- Report — Document findings with severity ratings and actionable fix recommendations
- Verify coverage targets are met before closing; flag gaps explicitly
- 定义范围 — 明确测试对象与适用的测试类型
- 制定策略 — 从功能、性能、安全多个维度规划测试方案
- 编写测试 — 实现带有合理断言的测试用例(见下方示例)
- 执行测试 — 运行测试并收集结果
- 若测试失败:对失败进行分类(断言错误 vs 环境问题/flaky问题),修复根本原因后重跑
- 若测试存在flaky问题:隔离顺序依赖,检查异步处理逻辑,添加重试或稳定化逻辑
- 输出报告 — 记录测试发现,标注严重等级并给出可落地的修复建议
- 关闭前需验证覆盖率达标;明确标记覆盖率缺口
Quick-Start Example
快速入门示例
A minimal Jest unit test illustrating the key patterns this skill enforces:
js
// ✅ Good: meaningful description, specific assertion, isolated dependency
describe('calculateDiscount', () => {
it('applies 10% discount for premium users', () => {
const result = calculateDiscount({ price: 100, userTier: 'premium' });
expect(result).toBe(90); // specific outcome, not just truthy
});
it('throws on negative price', () => {
expect(() => calculateDiscount({ price: -1, userTier: 'standard' }))
.toThrow('Price must be non-negative');
});
});Apply the same structure for pytest (, ) and other frameworks.
def test_…assert result == expected一个极简的Jest单元测试示例,展示了本技能倡导的核心模式:
js
// ✅ Good: meaningful description, specific assertion, isolated dependency
describe('calculateDiscount', () => {
it('applies 10% discount for premium users', () => {
const result = calculateDiscount({ price: 100, userTier: 'premium' });
expect(result).toBe(90); // specific outcome, not just truthy
});
it('throws on negative price', () => {
expect(() => calculateDiscount({ price: -1, userTier: 'standard' }))
.toThrow('Price must be non-negative');
});
});pytest(、)及其他框架也可沿用相同结构。
def test_…assert result == expectedReference Guide
参考指南
Load detailed guidance based on context:
<!-- TDD Iron Laws and Testing Anti-Patterns adapted from obra/superpowers by Jesse Vincent (@obra), MIT License -->
| Topic | Reference | Load When |
|---|---|---|
| Unit Testing | | Jest, Vitest, pytest patterns |
| Integration | | API testing, Supertest |
| E2E | | E2E strategy, user flows |
| Performance | | k6, load testing |
| Security | | Security test checklist |
| Reports | | Report templates, findings |
| QA Methodology | | Manual testing, quality advocacy, shift-left, continuous testing |
| Automation | | Framework patterns, scaling, maintenance, team enablement |
| TDD Iron Laws | | TDD methodology, test-first development, red-green-refactor |
| Testing Anti-Patterns | | Test review, mock issues, test quality problems |
可根据场景加载详细指南:
<!-- TDD铁则与测试反模式改编自 Jesse Vincent (@obra) 的 obra/superpowers 项目,MIT 许可证 -->
| 主题 | 参考文档 | 适用场景 |
|---|---|---|
| 单元测试 | | Jest、Vitest、pytest 相关模式 |
| 集成测试 | | API 测试、Supertest |
| E2E 测试 | | E2E 测试策略、用户流程 |
| 性能测试 | | k6、负载测试 |
| 安全测试 | | 安全测试检查清单 |
| 测试报告 | | 报告模板、测试发现 |
| QA 方法论 | | 手工测试、质量推动、左移测试、持续测试 |
| 自动化测试 | | 框架模式、规模化、维护、团队赋能 |
| TDD 铁则 | | TDD 方法论、测试先行开发、红-绿-重构 |
| 测试反模式 | | 测试评审、Mock 问题、测试质量问题 |
Constraints
约束条件
MUST DO
- Test happy paths AND error/edge cases (e.g., empty input, null, boundary values)
- Mock external dependencies — never call real APIs or databases in unit tests
- Use meaningful descriptions that read as plain-English specifications
it('…') - Assert specific outcomes (), not just truthiness
expect(result).toBe(90) - Run tests in CI/CD; document and remediate coverage gaps
MUST NOT
- Skip error-path testing (e.g., don't test only the success branch of a try/catch)
- Use production data in tests — use fixtures or factories instead
- Create order-dependent tests — each test must be independently runnable
- Ignore flaky tests — quarantine and fix them; don't just re-run until green
- Test implementation details (internal method calls) — test observable behaviour
必须遵守
- 必须测试正向路径 AND 错误/边界用例(例如空输入、null、边界值)
- 必须Mock外部依赖 — 单元测试中严禁调用真实API或数据库
- 必须使用有意义的描述,读起来应像自然语言的规格说明
it('…') - 必须断言具体结果(),而非仅验证真值
expect(result).toBe(90) - 必须在CI/CD中运行测试;记录并修复覆盖率缺口
严禁事项
- 严禁跳过错误路径测试(例如不得只测试try/catch的成功分支)
- 严禁在测试中使用生产数据 — 请使用fixture或工厂函数替代
- 严禁编写依赖执行顺序的测试 — 每个测试必须可独立运行
- 严禁忽视flaky测试 — 需隔离并修复;不要只是反复重跑直到通过
- 严禁测试实现细节(内部方法调用) — 应测试可观测的行为
Output Templates
输出模板
When creating test plans, provide:
- Test scope and approach
- Test cases with expected outcomes
- Coverage analysis
- Findings with severity (Critical/High/Medium/Low)
- Specific fix recommendations
制定测试计划时,需包含以下内容:
- 测试范围与方案
- 带预期结果的测试用例
- 覆盖率分析
- 带严重等级的测试发现(严重/高/中/低)
- 具体的修复建议