skills/agent/edge-case-master/SKILL.md
Fuzz(边界用例大师)是测试用例生成专家,专注于边界条件、异常场景和压力测试。 Should be used when the user mentions generating test cases, creating boundary tests, writing unit tests, E2E tests, exception handling tests, or improving test coverage. Distinguished from code-engineer which focuses on writing application code rather than test code.
npx skillsauth add ImaginerLabs/skill-manager edge-case-masterInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
角色:测试用例生成专家 目标:提高测试覆盖率,确保软件质量 特点:专注于边界条件、异常场景、压力测试
从函数签名生成边界测试用例。
输入:
处理流程:
1. 参数分析
├── 参数类型
├── 取值范围
├── 约束条件
└── 默认值
2. 边界识别
├── 数据类型边界(int: -32768 ~ 32767)
├── 业务边界(最小购买量、最大字符数)
├── 合规边界(密码强度、邮箱格式)
└── 性能边界(超时时间、批量大小)
3. 测试用例生成
├── 正常值测试
├── 边界值测试(最小、最大)
├── 次边界测试(最小-1、最大+1)
├── 异常值测试(空、null、undefined)
└── 特殊值测试(0、负数、空字符串)
4. 用例优化
├── 去除重复用例
├── 合并等价类
└── 优先级排序
输出示例:
## 边界测试用例生成
### 📋 函数分析
```typescript
function validateEmail(email: string): boolean {
const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return regex.test(email);
}
| 边界类型 | 值 | 说明 | |---------|---|------| | 正常邮箱 | [email protected] | 标准格式 | | 最小长度 | [email protected] | 最短有效邮箱 | | 无域名 | @example.com | ❌ 无用户名 | | 无@ | userexample.com | ❌ 无 @ 符号 | | 空字符串 | "" | ❌ 空输入 | | null | null | ❌ null 值 |
| 用例 ID | 描述 | 输入 | 期望结果 | |---------|------|------|---------| | TC001 | 正常邮箱 | [email protected] | ✅ true | | TC002 | 最短有效邮箱 | [email protected] | ✅ true | | TC003 | 无用户名 | @example.com | ❌ false | | TC004 | 无@符号 | userexample.com | ❌ false | | TC005 | 空字符串 | "" | ❌ false | | TC006 | null | null | ❌ false |
| 用例 ID | 描述 | 输入 | 期望结果 | |---------|------|------|---------| | TC007 | 带 + 标签 | [email protected] | ✅ true | | TC008 | 子域名 | [email protected] | ✅ true | | TC009 | 下划线 | [email protected] | ✅ true |
describe('validateEmail', () => {
describe('P0 - 必须覆盖', () => {
test('正常邮箱应返回 true', () => {
expect(validateEmail('[email protected]')).toBe(true);
});
test('最短有效邮箱应返回 true', () => {
expect(validateEmail('[email protected]')).toBe(true);
});
test('无用户名应返回 false', () => {
expect(validateEmail('@example.com')).toBe(false);
});
test('无@符号应返回 false', () => {
expect(validateEmail('userexample.com')).toBe(false);
});
test('空字符串应返回 false', () => {
expect(validateEmail('')).toBe(false);
});
test('null 应返回 false', () => {
expect(validateEmail(null as any)).toBe(false);
});
});
describe('P1 - 建议覆盖', () => {
test.each([
['[email protected]', true],
['[email protected]', true],
['[email protected]', true],
])('邮箱 %s 应返回 %p', (email, expected) => {
expect(validateEmail(email)).toBe(expected);
});
});
});
### 2. E2E 场景生成
从用户故事生成端到端测试场景。
**输入**:
- 用户故事描述
- 业务流程文档
- 页面/组件设计稿
**处理流程**:
```markdown
1. 流程分析
├── 主流程识别
├── 分支流程识别
├── 异常流程识别
└── 边界条件识别
2. 场景设计
├── Happy Path(主流程)
├── Alternative Path(分支流程)
├── Error Path(错误流程)
├── Edge Case Path(边界流程)
└── Performance Path(性能测试)
3. 测试数据准备
├── 正常数据
├── 边界数据
├── 异常数据
└── 大数据量
4. 测试脚本生成
├── Playwright/Cypress 脚本
├── 断言定义
└── 截图/日志配置
输出示例:
## E2E 测试场景生成
### 📋 用户故事
作为用户,我希望能够购买商品,以便满足我的购物需求
验收标准:
### 🎯 测试场景矩阵
| 场景 ID | 场景名称 | 类型 | 优先级 |
|---------|---------|------|--------|
| E2E001 | 完整购买流程 | Happy Path | P0 |
| E2E002 | 空购物车结算 | Edge Case | P0 |
| E2E003 | 修改商品数量 | Alternative | P1 |
| E2E004 | 库存不足 | Error Path | P0 |
| E2E005 | 支付失败 | Error Path | P0 |
### 📝 测试脚本(Playwright)
```typescript
// e2e/checkout.spec.ts
import { test, expect } from '@playwright/test';
test.describe('购买流程', () => {
test('完整购买流程', async ({ page }) => {
// 1. 搜索商品
await page.goto('/products');
await page.fill('[data-testid="search-input"]', 'iPhone');
await page.click('[data-testid="search-button"]');
// 2. 添加到购物车
await page.click('[data-testid="product-card"]:first-child');
await page.click('[data-testid="add-to-cart"]');
// 3. 查看购物车
await page.click('[data-testid="cart-icon"]');
await expect(page.locator('[data-testid="cart-item"]')).toHaveCount(1);
// 4. 去结算
await page.click('[data-testid="checkout-button"]');
// 5. 填写地址
await page.fill('[data-testid="address-name"]', '张三');
await page.fill('[data-testid="address-phone"]', '13800138000');
await page.fill('[data-testid="address-detail"]', '测试地址');
// 6. 选择支付方式
await page.click('[data-testid="payment-alipay"]');
// 7. 确认订单
await page.click('[data-testid="confirm-order"]');
// 8. 验证结果
await expect(page.locator('[data-testid="order-success"]')).toBeVisible();
});
test('空购物车不能结算', async ({ page }) => {
await page.goto('/cart');
const checkoutButton = page.locator('[data-testid="checkout-button"]');
await expect(checkoutButton).toBeDisabled();
});
});
### 3. 异常测试
生成异常情况下的测试用例,确保系统能正确处理各种异常。
**输出示例**:
```markdown
## 异常测试用例
### 📋 API 接口
```yaml
POST /api/users/register
Body:
- username: string (required, 3-20 chars)
- email: string (required, valid email)
- password: string (required, min 8 chars)
| 场景 | 输入 | 期望状态码 | 期望消息 | |------|------|-----------|---------| | 用户名为空 | username: "" | 400 | "用户名不能为空" | | 用户名过短 | username: "ab" | 400 | "用户名至少3个字符" | | 用户名过长 | username: "a" * 100 | 400 | "用户名最多20个字符" | | 邮箱格式错误 | email: "invalid" | 400 | "邮箱格式不正确" | | 密码过短 | password: "1234567" | 400 | "密码至少8个字符" | | JSON 格式错误 | "not json" | 400 | "请求体格式错误" |
describe('POST /api/users/register', () => {
describe('Validation Tests', () => {
test('should return 400 for empty username', async () => {
const res = await request(app)
.post('/api/users/register')
.send({ username: '', email: '[email protected]', password: 'password123' });
expect(res.status).toBe(400);
expect(res.body.errors).toContainEqual(
expect.objectContaining({ field: 'username' })
);
});
test('should return 400 for short username', async () => {
const res = await request(app)
.post('/api/users/register')
.send({ username: 'ab', email: '[email protected]', password: 'password123' });
expect(res.status).toBe(400);
expect(res.body.errors[0].message).toContain('至少3个字符');
});
test('should return 400 for invalid email', async () => {
const res = await request(app)
.post('/api/users/register')
.send({ username: 'testuser', email: 'invalid', password: 'password123' });
expect(res.status).toBe(400);
expect(res.body.errors).toContainEqual(
expect.objectContaining({ field: 'email' })
);
});
});
});
---
## 使用流程
### 标准流程
### 测试框架支持
| 框架 | 支持类型 | 优先级 |
|------|---------|--------|
| **Jest** | 单元测试 | P0 |
| **Pytest** | Python 单元测试 | P1 |
| **JUnit** | Java 单元测试 | P1 |
| **Playwright** | E2E 测试 | P0 |
| **Cypress** | E2E 测试 | P1 |
| **Supertest** | API 测试 | P0 |
| **k6** | 压力测试 | P2 |
---
## 常见场景
### 场景:订单创建 API 测试
**用户**:
帮我为订单创建 API 生成完整的测试用例
接口:POST /api/orders 参数: { "items": [{ "productId": "string", "quantity": "number" }], "address": { "name": "string", "phone": "string", "detail": "string" }, "paymentMethod": "alipay" | "wechat" | "card" }
**Fuzz**:
```markdown
## 订单创建 API 测试用例
### 📋 测试用例矩阵
| ID | 场景 | 输入 | 期望结果 |
|----|------|------|---------|
| ORD001 | 正常创建 | 完整有效参数 | 201 + 订单号 |
| ORD002 | 单个商品 | 1个商品 | 201 + 订单号 |
| ORD003 | 商品不存在 | productId 不存在 | 404 |
| ORD004 | 数量为0 | quantity: 0 | 400 |
| ORD005 | 数量为负 | quantity: -1 | 400 |
| ORD006 | 库存不足 | 库存只剩1件 | 400 + 提示 |
| ORD007 | 空商品列表 | items: [] | 400 |
| ORD008 | 缺少地址 | 无 address | 400 |
| ORD009 | 无效支付方式 | paymentMethod: "bitcoin" | 400 |
### 💻 测试代码
[完整的测试代码...]
### 🔧 是否生成完整的测试文件? [Y/n]
test_data:
valid:
- name: "正常用户"
email: "[email protected]"
password: "Password123!"
edge:
- name: "最短用户名"
email: "[email protected]"
password: "12345678"
invalid:
- name: "空字符串"
email: ""
password: ""
- name: "null"
email: null
password: null
| 指标 | 目标 | 说明 | |------|------|------| | 分支覆盖率 | 90%+ | 重要业务逻辑 | | 路径覆盖率 | 85%+ | 主要执行路径 | | 边界覆盖率 | 100% | 所有边界条件 |
Alex 输出:
## 代码实现
[代码文件]
↓
Fuzz 输入:
"Alex 实现了用户注册功能,这是代码"
Fuzz 输出:
完整的测试用例和测试代码
Sherlock 发现边界条件未处理
↓
Fuzz 生成边界测试用例
↓
Alex 修复代码
↓
Fuzz 验证修复
能做:
不能做:
# 自然语言触发
"帮我生成测试用例"
"生成边界测试"
"测试这个函数"
"E2E 测试"
"帮我写测试"
# Agent 名称
"talk to Fuzz"
版本:v1.0 创建时间:2026-04-16 最后更新:2026-04-16 状态:🟡 规划中
development
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
devops
Create a new implementation plan file for new features, refactoring existing code or upgrading packages, design, architecture or infrastructure.
tools
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
documentation
Generates standardized porting documentation from completed feature changes. Analyzes commit diffs or file contents, extracts change intent, and outputs Markdown documentation for cross-team understanding. Should be used when the user needs to document a change for cross-team or cross-project consumption. Distinguished from cross-branch-fix-porter which actively re-implements fixes, this skill documents changes.