Install
$ agentstack add skill-yuaicode-ai-skills-test-gen-zh ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
test-gen-zh — 测试用例生成
给指定函数或文件自动生成测试,配合 TDD 工作流,覆盖正常路径、边界值、错误路径,而不是凑覆盖率数字。
何时触发
用户说以下任意一种:
- "帮我生成测试 / 给这个函数写测试 / 补测试用例"
- "test-gen-zh \"
- "这个函数没测试,帮我写一下"
- "TDD — 先给我写 test"
用法
1. 探测测试框架
bash /bin/detect-framework.sh [项目目录]
# 输出:go test | jest | vitest | flutter test | pytest | cargo test | unknown
# 默认当前目录;不存在或识别不了均输出 unknown
2. 流程
- 探测框架:跑
bin/detect-framework.sh确认测试框架。若输出unknown,询问用户用哪个框架后继续。 - 读实现:读目标函数 / 文件,理解:
- 函数签名(参数类型、返回值、可能抛出的错误)
- 核心逻辑分支
- 依赖(外部调用、IO、全局状态)
- 参照已有测试风格:若项目里有现成测试文件,先读一个做风格参照(命名、断言库、fixture 写法)。
- 生成测试:按该框架惯例写测试,三条路径都要覆盖:
- 正常路径:典型入参 → 预期返回值
- 边界值:空值、零值、最大/最小、类型边界
- 错误路径:非法输入、外部依赖失败、超时、panic/exception
- 确认可跑:给出完整可执行的测试命令,若有 mock/stub 依赖一并给出。
输出格式
## 测试生成报告
**框架**:`` (由 detect-framework.sh 探测)
**测试文件**:``
### 覆盖清单
- [ ] 正常路径:
- [ ] 边界值:
- [ ] 错误路径:
### 测试代码
\`\`\`
\`\`\`
### 运行方式
\`\`\`bash
\`\`\`
硬规则
- 测真实行为,不是凑覆盖率:每个 case 必须有明确的"验证什么",不写"assert True"这类无效断言。
- 不臆造被测代码的行为:拿不准函数在某边界返回什么,先读实现确认,再写断言。不要猜。
- 遵循项目已有测试风格:命名、fixture、mock 方式都跟项目已有测试保持一致;若无已有测试则按框架官方惯例。
- 依赖隔离:有 IO / 网络 / DB 调用的地方给出 mock/stub/fake 方案,不要生成需要真实环境才能跑的测试。
- 输出可直接复制执行:测试代码完整(含 import),运行命令可直接粘贴跑。
- 不写任何被测代码:只写测试;若被测函数不存在,说明后让用户先实现。
边界
- 不依赖外部服务;
bin/detect-framework.sh纯 bash + grep,离线可用。 - 不修改被测文件。
- 仅生成测试代码,不执行跑测试(可在"运行方式"里给命令)。
- 框架识别不了时(
unknown)会明确告知并询问用户。
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: YuAICode
- Source: YuAICode/ai-skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.