AINow
📢 赞助位招租 · 月访问 XXXX · 联系 weixin_xxx
了解详情
返回 Skill 列表
编程开发进阶

自动化测试生成 Skill

根据代码自动生成单元测试、集成测试、端到端测试。

📋 SKILL.md 完整代码

---
name: test-gen-skill
description: >-
  根据代码自动生成单元测试、集成测试、端到端测试。
  Use when working on test gen skill tasks.
allowed-tools: Read,Write,Bash
---

# 自动化测试生成 Skill

## Quick Start
1. Save as `~/.claude/skills/test-gen-skill/SKILL.md`
2. Restart Claude Code
3. Type `/test-gen-skill` or describe your task naturally
4. Claude auto-triggers when your task matches the description

## Instructions
- Understand the user's specific context and needs
- Apply domain best practices consistently
- Provide actionable, specific guidance with examples
- Verify all outputs before presenting to user

## Gotchas
- Test with a fresh Claude instance after changes
- Keep SKILL.md under 500 lines; use references/ for details
- Description is the trigger key — make it specific and keyword-rich

🚀 怎么用

1. 复制上面的 SKILL.md 代码
2. 保存为 ~/.claude/skills/test-gen-skill/SKILL.md
3. 重启 Claude Code
4. 输入 /test-gen-skill 或直接描述任务触发
5. AI 自动按 Skill 流程执行

测试类型

单元测试(每个函数/组件的独立测试)→集成测试(多个模块协作的测试)→端到端测试(模拟用户操作的完整流程测试)。AI 自动覆盖:正常情况+边界情况+异常情况+空值处理。遇到 Bug 先写测试再修——确保 Bug 不再回来。