Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

generate-test-cases生成测试用例

Agent Skill

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

总安装

1,001

周安装

43

GitHub Stars

9

下载量

351
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

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

简介

用于辅助测试设计、用例整理和回归验证。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中编写单元测试或端到端测试。
  • 通过 GitHub 安装,使用 npx skills add 命令添加技能。
  • 需确认测试框架和运行命令,避免为了通过测试而改坏逻辑。
  • generate-test-cases 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Generate Test Cases Skill

You will analyze code and generate a list of test cases that should be written for a given method/class. This skill outputs test case descriptions only — it does NOT generate actual test code.

Target to analyze: $ARGUMENTS

Quality Standards

  • Take your time to analyze the code thoroughly before listing test cases.
  • Quality is more important than speed — read all relevant source files and rules carefully.
  • Do not skip reading the dependency classes. Understanding the full context produces better test cases.

Instructions

Step 1: Read Rules and Analyze Context

  1. Read the rules from ./rules/general/ directory (see Rules Reference below)
  2. Read the target source file/class/method specified above
  3. Read dependencies: Follow imports to read DTOs, entities, enums, and other types referenced by the target (as specified in code-context-analysis rule)
  4. Check for existing tests: Search for existing test classes covering this target (as specified in existing-test-awareness rule) — if found, read it fully and focus only on behaviors not yet covered

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 specified format
  3. Do NOT generate actual test code — only the test case descriptions

Output Format

For each test case, provide:

## 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
  • getUser_forbidden_returns403

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, apply only the general rules and inform the user.

All behaviors already covered

If the existing test class already covers all identified behaviors, output a summary stating that coverage is complete. List what is already tested. Do not invent additional test cases to justify the analysis.


Example

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

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

Step 2: Agent outputs:

## Test Cases for OrderService.createOrder

### 1. createOrder_validRequest_savesAndReturnsOrder
- **Given:** Valid OrderRequest with productId "product-1" and quantity 5
- **When:** createOrder is called
- **Then:** Order is saved to repository and returned with generated ID
- **Code branch:** Success path

### 2. createOrder_nullProductId_throwsIllegalArgumentException
- **Given:** OrderRequest with null productId
- **When:** createOrder is called
- **Then:** IllegalArgumentException is thrown
- **Code branch:** Validation — productId null check
...

Rules Reference

CRITICAL: You MUST read and apply all rules from the following files before generating test cases:

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

General Rules (Always Apply)

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

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.23%
按下载量换算134

Claude

30.95%
按下载量换算109

Cursor

16.77%
按下载量换算59

Gemini CLI

9.47%
按下载量换算33

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

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

安装前确认

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

来源信息

继续浏览同类 Skills