Token导航 LogoToken导航

Agent Skill · 研究检索

generate-tests(生成测试)

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

generate-tests 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 49,632。

总安装 643周安装 26GitHub Stars 9下载 202核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:generate-tests(生成测试)
来源仓库:https://github.com/clear-solutions/unit-tests-skills
仓库路径:skills/generate-tests
安装命令:
npx skills add https://github.com/clear-solutions/unit-tests-skills --skill generate-tests
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/clear-solutions/unit-tests-skills --skill generate-tests

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

基于代码分析生成高质量单元测试,支持多种测试框架和夹具数据规范。适合辅助测试设计、自动化用例编写及回归验证场景。严格遵循质量优先原则,逐层读取源码与规则文件,避免跳过必要步骤。需确认项目测试框架与运行命令,涉及外部服务时应区分模拟与真实环境。

generate-tests 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/generate-tests

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/clear-solutions/unit-tests-skills --skill gene…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

generate-tests 怎么安装?

在终端执行 npx skills add https://github.com/clear-solutions/unit-tests-skills --skill generate-tests。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

generate-tests 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

generate-tests 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

generate-tests 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

generate-tests 用的人多吗?

公开数据是累计安装 643 次,近一周安装 26 次,下载 202 次,GitHub 9 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

generate-tests 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
generate-tests

生成测试 · 本页

6439需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Generate Tests Skill

You will analyze code and generate high-quality unit tests for a given target.

Target to test: $ARGUMENTS

Quality Standards

  • Take your time to analyze the code thoroughly before generating test cases.
  • Quality is more important than speed — read all relevant source files and rules carefully.
  • Do not skip any step in the workflow below. Every step exists for a reason.
  • Do not take shortcuts with test data — read the actual classes to use correct constructors and fields.

Instructions

Step 1: Read Rules and Analyze Context

  1. Read the relevant rules from ./rules/tests/ based on code type (see Rules Reference below)
  2. Read the target source file/class/method
  3. Read dependencies: Follow imports to read DTOs, entities, enums, custom exceptions, and other types referenced by the target (as specified in code-context-analysis rule)
  4. Check for existing tests: Search for {ClassName}Test or {ClassName}Tests in the test directory (as specified in existing-test-awareness rule)

- If found, read fully — you will add missing tests to it, not create a new file - If not found, scan 2-3 neighboring test classes to learn project conventions

Step 2: Generate Test Cases

  1. Analyze ALL code branches, including:

- Success paths - Error/exception paths - Validation logic - Private/protected methods called by the target - Security annotations (if present)

  1. Apply the INCLUDE/EXCLUDE rules strictly
  2. Output the list of test cases in the format below — do NOT generate test code yet
Test Case Output Format
## Test Cases for {ClassName}.{methodName}

### 1. {testMethodName}
- **Given:** {preconditions/input state}
- **When:** {action being tested}
- **Then:** {expected outcome}
- **Code branch:** {which code path this covers}

### 2. {testMethodName}
...
Naming Convention

Test method name format: {testedMethod}_{givenState}_{expectedOutcome}

Examples:

  • calculateTotal_validProducts_returnsSum
  • calculateTotal_emptyList_throwsIllegalArgumentException
  • getUser_unauthorized_returns401

Step 3: Ask for User Review

After outputting test cases, use the AskUserQuestion tool to ask the user:

Question: "Test cases are ready. Proceed with generating test code?"
Header: "Next step"
Options:
  - Label: "Yes, generate tests" / Description: "Proceed to generate test files from the test cases above"
  - Label: "No, let me review first" / Description: "Stop here so I can review and adjust the test cases"
  • If user selects "Yes", proceed to Step 4
  • If user selects "No", STOP and wait for further instructions

Step 4: Generate Test Code

  1. Determine code type and apply the matching rules:

- Controller → Apply controller-test-rules.md (use @WebMvcTest, MockMvc patterns) - Service / Domain logic → Apply domain-service-rules.md (use @ExtendWith(MockitoExtension.class), Mockito patterns) - Repository / Messaging / Other types → Apply domain-service-rules.md as baseline; inform the user that type-specific rules are not yet available - All Java code → Always apply java-test-template.md, argument-matching.md, json-serialization.md regardless of code type

  1. If an existing test class was found in Step 1, add new test methods to it (do not create a duplicate file)
  2. Generate tests following all rules and the test cases from Step 2
  3. Create or update the test file using the Write tool

Step 5: Verify Compilation and Execution

  1. Run compilation and fix any issues (max 5 attempts — see compilation-verification.md)
  2. Run the generated test class to verify all tests pass (see test-execution-verification.md)
  3. Fix any failing tests — do NOT modify production code
  4. If a test cannot be fixed after 3 attempts, remove it and inform the user

Troubleshooting

Target file not found

If the specified target does not exist, inform the user with the exact path you searched and ask for clarification.

Unsupported language

If the target code is in a language without specific rules (not Java), apply only the general rules and inform the user that language-specific conventions may need manual review.

Compilation keeps failing

If compilation fails after 5 attempts:

  1. Stop and show the user the remaining errors
  2. Suggest possible causes (missing dependencies, incompatible versions)
  3. Ask the user to resolve the build issue before continuing

Tests fail due to production code behavior

If tests fail because the production code behaves differently than expected:

  1. Do NOT modify production code
  2. Fix the test to match actual behavior
  3. If the behavior seems like a bug, add a comment: // NOTE: current behavior may be a bug — {description}

Example

User says: "/generate-tests src/main/java/com/example/service/OrderService.java"

Step 1: Agent reads rules, reads OrderService.java, reads OrderRequest.java,
        Order.java, OrderRepository.java (dependencies), checks for
        existing OrderServiceTest.java

Step 2: Agent outputs 7 test cases covering:
        - createOrder success path
        - createOrder with invalid request (validation)
        - processPayment success
        - processPayment failure
        - calculateTotal with products
        - calculateTotal with empty list
        - cancelOrder for non-existent order

Step 3: Agent asks user to review. User says "Yes, generate tests".

Step 4: Agent generates OrderServiceTest.java with @ExtendWith(MockitoExtension.class),
        mocked repository and payment service, 7 test methods.

Step 5: Agent runs `mvn test -Dtest=OrderServiceTest -q`, all tests pass.

Result: Complete test file delivered with 7 passing tests.

Rules Reference

CRITICAL: You MUST read and apply all relevant rules from the ./rules/tests/ directory.

Maintenance note: General rules in ./rules/tests/general/ are shared with the generate-test-cases skill (which has copies in rules/general/). When updating rules, keep both locations in sync.

General Rules (Always Apply)

  • general/test-case-generation-strategy.md - INCLUDE/EXCLUDE criteria
  • general/naming-conventions.md - Test naming format
  • general/general-principles.md - Core testing principles (Given-When-Then, actual/expected)
  • general/technology-stack-detection.md - Detect language and framework
  • general/what-makes-good-test.md - Clarity, Completeness, Conciseness, Resilience
  • general/cleanly-create-test-data.md - Use helpers and builders for test data
  • general/keep-cause-effect-clear.md - Effects follow causes immediately
  • general/no-logic-in-tests.md - KISS > DRY, avoid logic in assertions
  • general/keep-tests-focused.md - One scenario per test
  • general/test-behaviors-not-methods.md - Separate tests for behaviors
  • general/verify-relevant-arguments-only.md - Only verify relevant mock arguments
  • general/prefer-public-apis.md - Test public APIs over private methods
  • general/existing-test-awareness.md - Check for existing tests, match project conventions
  • general/code-context-analysis.md - Read dependencies before writing tests

Java Unit Tests

  • java/unit/java-test-template.md - Basic template, FORBIDDEN annotations
  • java/unit/json-serialization.md - Use explicit JSON literals
  • java/unit/argument-matching.md - Use ArgumentCaptor, not any()
  • java/unit/logging-rules.md - OutputCaptureExtension for logs
  • java/unit/domain-service-rules.md - Mockito patterns for services
  • java/unit/controller-test-rules.md - @WebMvcTest and MockMvc patterns for controllers

Post-Generation

  • post-generation/compilation-verification.md - Verify compilation
  • post-generation/test-execution-verification.md - Verify tests pass

平台分布

Codex

34.89%
按下载量换算70

Claude

29.1%
按下载量换算59

Cursor

19.68%
按下载量换算40

Gemini CLI

9.78%
按下载量换算20

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills