majiayu000/claude-skill-registry-data/test-generator-laolaoshiren-claude-code-skills-z
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Tainted
Author "majiayu000" has blocked skill(s)
自动生成单元测试:识别函数逻辑、覆盖边界条件、生成可运行测试代码
Install
npx vskill@latest install majiayu000/claude-skill-registry-data/test-generator-laolaoshiren-claude-code-skills-zSKILL.md
测试生成器
触发条件
当用户要求"生成测试"、"写单元测试"、"为 XX 函数写测试"、"增加测试覆盖率"时激活此技能。
工作流程
1. 分析目标代码
- 读取目标文件,识别函数/类的输入输出
- 分析参数类型、返回值、副作用
- 识别依赖关系(数据库、API、文件系统等)
2. 确定测试策略
- 纯函数:参数化测试,覆盖正常/边界/异常输入
- 类方法:测试初始化、正常调用、状态变化
- 异步函数:测试成功路径、超时、网络错误
- 含副作用的函数:使用 mock/stub 隔离依赖
3. 生成测试用例
每个函数至少覆盖:
- ✅ 正常输入(happy path)
- ⚠️ 边界条件(空值、零值、极大值、空字符串/数组)
- ❌ 异常输入(类型错误、格式错误)
- 🔗 依赖失败(网络超时、数据库异常)
4. 输出格式
根据项目语言和测试框架生成对应代码:
Python (pytest)
JavaScript (Jest)
Go (testing)
测试命名规范
- 中文项目:
test_函数名_场景描述或函数名_正常输入/边界条件/异常输入 - 英文项目:遵循项目现有命名风格
最佳实践
- 先读再写:理解代码逻辑后再生成测试,不要盲目覆盖
- 独立性:每个测试独立运行,不依赖执行顺序
- 可读性:测试名即文档,一看就知道测什么
- 适度 mock:外部依赖必须 mock,内部逻辑尽量不 mock
- 渐进式:先覆盖核心路径,再补充边界条件
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingtesting/test-generator-laolaoshiren-claude-code-skills-z/SKILL.md
Popularity
- Repository stars
- 24
- Repository forks
- 10
- 7-day trend score
- 21
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/majiayu000/claude-skill-registry-data/test-generator-laolaoshiren-claude-code-skills-z)