agentleFS
lightpointventureslightpointventures/claude-code-starter/skills/test/SKILL.md

test

Skill36 starsChanged 8 months agoMITView on GitHub

当用户想写测试、生成测试用例、给代码加单元测试时使用 — 自动生成测试,覆盖正常路径和边界情况

98 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use develop, document and 8 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.
  • bamechoSkill

    develop

    开发实施阶段详细规则;进入开发实施时读取;包含执行流程、代码规范、一致性审计、方案包迁移

    Also in 6 projects that use this

  • nicolasestremSkill

    document

    Create focused documentation for specific components or features

    Also in 8 projects that use this

  • BugRogerSkill

    project

    Project lifecycle management. Dispatches to Ada.

    Also in 6 projects that use this

  • vltingSkill

    scope

    Interactive planning + orchestration. Approval-gated workflow covering saga→epic→task hierarchy via progressive scoping.

    Also in 5 projects that use this

  • bitwize-music-studioSkill

    tutorial

    Provides interactive guided album creation for new users. Use when the user is new to the plugin or asks for a walkthrough of the album creation process.

    Also in 3 projects that use this

  • kt057Skill

    check

    lint, typecheck, test を一括実行して結果をサマリーする

    Also in 8 projects that use this

The file

Files
SKILL.md

生成测试

为指定的代码自动生成测试用例,让用户不用自己写测试。

步骤

1. 确定测试目标

如果用户指定了函数或文件,直接读取。

如果没有指定,问:

你想给哪个函数或文件生成测试?

2. 分析代码

读取目标代码,分析:

  • 函数的输入参数和返回值
  • 正常执行路径
  • 可能的边界情况(空值、空列表、极大/极小值、类型错误)
  • 错误处理路径
  • 外部依赖(数据库、API、文件系统)

3. 检查项目的测试习惯

查看项目中已有的测试文件,了解:

  • 用的什么测试框架(pytest、jest、go test 等)
  • 测试文件的命名和存放位置
  • 已有的测试风格和模式(比如是否用 fixture、mock)

如果项目没有已有测试,根据技术栈选择最常用的测试框架。

4. 生成测试用例

按以下优先级生成测试:

  1. 正常路径 — 最基本的输入,验证核心功能正确
  2. 边界情况 — 空值、零值、极端值、特殊字符
  3. 错误处理 — 非法输入、异常情况是否正确处理

规则:

  • 每个测试用例只测试一个行为,命名要清晰说明测试什么
  • 测试数据要具体、有意义,不要用 "test"、"foo" 这类占位符
  • 如果有外部依赖,用 mock 隔离
  • 与项目已有的测试风格保持一致

5. 确认并写入

展示生成的测试代码,告诉用户:

生成了 N 个测试用例,覆盖了 xxx。要我写入到测试文件吗?

用户确认后,写入对应的测试文件。然后运行测试确认全部通过。

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.