generate-test-cases
Skill55 starsChanged 59 days agoMITView on GitHub
Use when the user asks to analyze code for test coverage, list what test cases are needed, or review testing strategy — WITHOUT generating actual test code.
In this repository3 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- generate-testsSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Do not skip reading the dependency classes.
- Very specific: line 28
Read dependencies: Follow imports to read DTOs, entities, enums, and other types referenced by the target (as specified in …
- Very specific: line 29
Check for existing tests: Search for existing test classes covering this target (as specified in existing-test-awareness rule) — if found, …
- Distinctive: line 41
Stop at the descriptions — the list itself is this skill's deliverable
- Very specific: line 66
Test method name format: {testedMethod}_{givenState}_{expectedOutcome}
- Distinctive: line 79
If the specified target does not exist, inform the user with the exact path you searched and ask for clarification.
- Distinctive: line 82
If the target code is in a language without specific rules, apply only the general rules and inform the user.
- Distinctive: line 85
If the existing test class already covers all identified behaviors, output a summary stating that coverage is complete.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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
- Read the rules from
./rules/general/directory (see Rules Reference below) - Read the target source file/class/method specified above
- Read dependencies: Follow imports to read DTOs, entities, enums, and other types referenced by the target (as specified in
code-context-analysisrule) - Check for existing tests: Search for existing test classes covering this target (as specified in
existing-test-awarenessrule) — if found, read it fully and focus only on behaviors not yet covered
Step 2: Generate Test Cases
- Analyze ALL code branches, including:
- Success paths
- Error/exception paths
- Validation logic
- Private/protected methods called by the target
- Security annotations (if present)
- Apply the INCLUDE/EXCLUDE rules strictly
- Output the list of test cases in the specified format
- Stop at the descriptions — the list itself is this skill's deliverable
- Close by naming the next step:
generate-tests <target>takes this list as its plan and writes the code from it. Hand the list forward as it stands — the user can review or amend it first
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_returnsSumcalculateTotal_emptyList_throwsIllegalArgumentExceptiongetUser_unauthorized_returns401getUser_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 thegenerate-testsskill (which has copies inrules/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
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
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.

