test-generator
Skill1 starsChanged 3 months agoMITView on GitHub
根据函数/方法代码自动生成单元测试骨架。自动识别项目测试框架和已有测试风格,覆盖正常路径、边界条件、异常处理、依赖 mock。用户说"生成测试"、"写单测"、"加测试"、"test this"、"单元测试"时触发。
25 other projects use a version of this.
Adopted by
Most recently taken up by
- u9401066/zotero-keepertheir own version, first seen Nov 8, 2026
- Data-Wise/crafttheir own version, first seen Oct 31, 2026
- u9401066/pubmed-search-mcptheir own version, first seen Oct 20, 2026
- aidankaokao/claude-skillstheir own version, first seen Oct 9, 2026
- jablonkai/skillstheir own version, first seen Oct 1, 2026
- Ecoa-PUC-Rio/GAIDEtheir own version, first seen Aug 19, 2026
Used with
Projects with it also use log-analyzer, security-reviewer and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
nek1987Skilllog-analyzer
Parse and analyze application logs to identify errors, patterns, and insights.
Also in 3 projects that use this
JeffallanSkillsecurity-reviewer
Identifies security vulnerabilities, generates structured audit reports with severity ratings, and provides actionable remediation guidance. Use when conducting security audits, reviewing code for vulnerabilities, or analyzing infrastructure security. Invoke for SAST scans, penetration testing, DevSecOps practices, cloud security reviews, dependency audits, secrets scanning, or compliance checks. Produces vulnerability reports, prioritized recommendations, and compliance checklists.
Also in 3 projects that use this
GoogleSkillcode-review
Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.
Also in 4 projects that use this
Other versions25 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 25
- laolaoshiren/claude-code-skills-zh★ 907same name
- u9401066/pubmed-search-mcp★ 28same name
- Ecoa-PUC-Rio/GAIDE★ 8same name
- jcarlos78/GAIDE★ 8same name
- u9401066/zotero-keeper★ 7same name
- bestdeejay-design/agent-skills★ 6same name
- Data-Wise/craft★ 4same name
- u9401066/nsforge-mcp★ 4same name
- Nembie/claude-code-skills★ 3same name
- suxiao1824308603/Qoder-devtools-skills★ 3same name
15 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- concise-modeSkill
- config-doctorSkill
- git-workflowSkill
- project-onboardingSkill
- refactor-advisorSkill
- release-notesSkill
The file
Files
test-generator · 单元测试生成器
根据选中代码或指定函数,生成符合项目风格的单元测试骨架。
流程
1. 识别上下文
- 检测项目使用的测试框架:检查
package.json、Cargo.toml、go.mod、requirements*.txt、pyproject.toml等 - 定位已有测试文件,学习:
- 文件命名约定(
*.test.ts/*.spec.ts/test_*.py/*_test.go) - 测试结构(
describe/it、test_前缀函数、#[test]) - mock/stub 方式(jest.mock、sinon、unittest.mock、gomock)
- 断言风格(
expect().toBe()、assert.Equal()、self.assertEqual())
- 文件命名约定(
2. 分析目标函数
- 参数类型、返回值类型、泛型约束
- 分支路径:每个 if/else、switch/case、循环的典型场景
- 外部依赖:网络请求、文件 I/O、数据库、第三方 SDK
- 可抛出的异常/错误
3. 生成测试骨架
describe('functionName', () => {
// 正常路径
it('should return expected result for valid input', () => { /* 典型输入 → 预期输出 */ })
// 边界条件
it('should handle empty input gracefully', () => { /* 空数组/空字符串/null/undefined */ })
it('should handle boundary values correctly', () => { /* 临界值:0, -1, MaxInt, 单元素 */ })
// 异常处理
it('should throw when required argument is missing', () => { /* 参数校验 */ })
it('should return error when external call fails', () => { /* 模拟依赖失败 */ })
// 依赖调用
it('should call dependency with correct arguments', () => { /* 验证 mock 被正确调用 */ })
})4. 原则
- 匹配现有风格:函数名、结构、断言方式全对齐项目已有代码,新人不觉得是两拨人写的
- 只写能跑的逻辑:不填
// TODO、expect(true).toBe(true)这类占位符 - 一个测试一个断言:每个
it/test只验证一件事,失败时一眼知道原因 - 命名即文档:
it('should do X when Y')/test_<函数名>_<场景>_<预期> - 不重复已有:先检查是否已有相同逻辑的测试,避免生成重复用例
- 不过度 mock:只 mock I/O 和外部边界,纯函数和内部工具不过度隔离
- 覆盖关键路径:线上出过问题的路径必须覆盖;优先覆盖主力路径而非冷门分支
5. 输出格式
直接在目标测试文件中追加代码,或新建测试文件(如果该函数还没有对应测试文件)。生成后:
- 标注每个测试覆盖的场景(一行注释)
- 如果项目有测试覆盖率门槛,提示当前覆盖变化
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

