🧪
QualityPython

Test Generator

by laolaoshiren

Test Generator is a Quality skill for Claude Code, published by laolaoshiren in claude-code-skills-zh.

786 stars84 forkson laolaoshiren/claude-code-skills-zhAdded 2026/08/23+1% in starsRepository updated 2026/08/23
ai-agentawesome-listclaude-codeclaude-skillsdeveloper-toolsprompt-engineeringskills
Install in seconds
Install Test Generator
Copy Test Generator into your Claude Code skills folder. Run the command in your terminal, or review the source on GitHub before installing.
terminal
npx degit https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/test-generator ~/.claude/skills/test-generator

Requires Node.js. Downloads this skill only — not the rest of the repository — into your Claude Code skills folder.

Without Node.js

git clone https://github.com/laolaoshiren/claude-code-skills-zh.git

Clones the whole repository, then copy the skill’s own directory into your skills folder yourself.

In this catalog

Source file
skills/test-generator/SKILL.md in laolaoshiren/claude-code-skills-zh
Installs to
~/.claude/skills/test-generator
Collection
One of 20 skills cataloged from this repository
Category
Quality1354 skills

What Test Generator does

Test Generator依据真实代码契约生成并验证单元测试或集成测试。用于补测试、提高覆盖率、生成回归用例或完善测试策略时,先读取现有测试与调用方,不猜测未明确的行为。

Test Generator is cataloged under Quality on DirSkills. Test Generator comes from a repository tagged ai-agent, awesome-list, claude-code, claude-skills and developer-tools.

Documentation

README

测试生成器

工作流程

1. 读取真实契约

检查目标代码及其:

  • 类型定义、公开文档、调用方和错误处理路径。
  • 现有测试、fixture、测试配置、依赖清单和项目测试命令。
  • 输入输出、副作用、状态变化、并发语义和系统边界。
  • 适用的仓库规则、Git 状态及本轮允许修改的范围。

区分“代码当前行为”和“产品期望行为”。两者冲突或契约不明确且会改变断言时,先列出证据与待确认假设;不要用测试固化猜测。

2. 选择测试层级

  • 纯逻辑优先使用快速、确定的单元测试。
  • 在系统边界隔离时间、随机数、文件系统、网络或第三方服务,避免 mock 被测模块的内部实现。
  • 需要验证真实组件协作时使用集成测试,可采用临时目录、测试数据库或受控服务,并确保资源隔离和清理。
  • 修复缺陷时先写能复现真实问题的最小回归用例,再验证修复。

只覆盖契约或可达路径中真实存在的正常、边界与失败场景。空值、类型错误、超时和数据库异常不是每个函数的固定要求。

3. 设计用例

每个用例应说明:

  • 对应的契约、缺陷或分支。
  • 输入与环境安排。
  • 可观察结果,而非内部实现细节。
  • 必要的清理和跨用例隔离。

优先参数化重复场景,并沿用仓库现有的测试命名、目录、fixture 和断言风格。不要因项目面向中文用户而强制使用中文函数名。

4. 实现最小测试

  • 只修改目标测试文件和确有必要的 fixture。
  • 不为了让测试通过而随意修改生产代码;若发现产品缺陷,单独报告或按用户要求修复。
  • 不复制未经核实的示例期望值,也不把实现细节写成永久契约。
  • Windows 与 Linux 使用路径 API、系统临时目录和显式编码,不硬编码分隔符、/tmp、换行、大小写、时区或 locale 行为。

5. 运行与复验

This is the opening of the README. Read the full README on GitHub.

Frequently asked about Test Generator

  • What else does laolaoshiren publish alongside Test Generator?

    Test Generator is one of 20 skills that DirSkills catalogs from laolaoshiren/claude-code-skills-zh, the repository it ships in. Its siblings there include API Tester, Changelog Generator and Chinese Code Reviewer. Each one is a separate skill with its own page in this directory, installs the same way Test Generator does, and is maintained by laolaoshiren in that same repository. The rest of the collection is listed on the laolaoshiren/claude-code-skills-zh page.

  • How does Test Generator compare to other Quality skills?

    Test Generator ranks #993 by stars among the 1354 Quality skills in this catalog. The most-starred ones next to it are Benchmark, Benchmark Optimization Loop and API Design Patterns. DirSkills ranks by the star count of the repository each skill ships in, so that order reflects how popular those repositories are rather than any review of Test Generator against them. Open each page to compare what they document and how they install.

More from laolaoshiren/claude-code-skills-zh

Test Generator is one of 20 skills cataloged on DirSkills from laolaoshiren/claude-code-skills-zh.

See all 20 skills