generate-test-cases — Claude Code command: test generation
generate-test-cases is a command for Claude Code that generates code tests, including unit, integration, and edge cases. It analyzes function structure and coverage.
MIT 630 installs updated 2026-10-24
npx claude-code-templates@latest --command testing/generate-test-casesWhat generate-test-cases does
Command parses function signatures, branches and complexity, then creates tests: positive scenarios, negative, boundary values, equivalence classes. Identifies dependencies and suggests mocks, checks path coverage and removes test duplication. Works with Jest and Vitest.
Accepts arguments: target file, scope (--unit, --integration, --edge-cases) or --automatic for full suite. Reads existing test patterns from *.test.* and *.spec.*, counts lines of code to estimate scope.
Creates test files, test data factories, mocks and maintenance guidelines. Available in Claude Code, Codex, GitHub Copilot and Gemini CLI; install via npx claude-code-templates@latest --command testing/generate-test-cases.
What it helps with
- write unit tests and integration tests for functions
- find edge cases and add tests for them
- create mocks for external dependencies and APIs
- check code coverage and fill gaps
- generate test data and factories
Example prompts for the agent
- Create tests for
src/utils/parser.tswith edge cases - Generate unit tests for all functions in
services/auth.js - Run automatic test generation for
controllers/with mocks and coverage
How to install generate-test-cases
1claude-code-templates
npx claude-code-templates@latest --command testing/generate-test-cases2Manually: put the files in place
.claude/commands/generate-test-cases.mdCall it with /generate-test-cases. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/generate-test-cases.mdCall it with /prompts:generate-test-cases. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/generate-test-cases.prompt.mdManually: put the files in place
.gemini/commands/generate-test-cases.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about generate-test-cases
How to install generate-test-cases in Claude Code?
Run npx claude-code-templates@latest --command testing/generate-test-cases, the command will appear in .claude/commands/generate-test-cases.md.
What does generate-test-cases command do?
Analyzes code, creates unit tests, integration tests, edge cases, mocks for dependencies and checks coverage. Supports Jest and Vitest.
What tests does generate-test-cases generate?
Positive and negative scenarios, boundary value tests, equivalence classes, mocks for external dependencies. Flag --automatic creates full suite.
Source text
generate-test-cases.md · MIT
---
allowed-tools: Read, Write, Edit, Bash
argument-hint: "[target] | [scope] | --unit | --integration | --edge-cases | --automatic"
description: Generate comprehensive test cases with automatic analysis and coverage optimization
---
# Generate Test Cases
Generate comprehensive test cases with automatic analysis and intelligent coverage: **$ARGUMENTS**
## Current Test Generation Context
- Target code: Analysis of $ARGUMENTS for test case generation requirements
- Test framework: !`find . -name "jest.config.*" -o -name "*.test.*" | head -1 && echo "Jest/Vitest detected" || echo "Detect framework"`
- Code complexity: !`find . -name "*.js" -o -name "*.ts" -o -name "*.py" | xargs wc -l 2>/dev/null | tail -1 | awk '{print $1}' || echo "0"` lines of code
- Existing patterns: !`find . -name "*.test.*" -o -name "*.spec.*" | head -3` test file patterns
## Task
Execute intelligent test case generation with comprehensive coverage and optimization:
**Generation Scope**: Use $ARGUMENTS to specify target file, unit tests, integration tests, edge cases, or automatic comprehensive generation
**Test Case Generation Framework**:
1. **Code Structure Analysis** - Parse function signatures, analyze control flow, identify branching paths, assess complexity metrics
2. **Test Pattern Recognition** - Analyze existing test patterns, identify testing conventions, extract reusable patterns, optimize consistency
3. **Input Space Analysis** - Identify parameter domains, analyze boundary conditions, discover edge cases, evaluate error conditions
4. **Test Case Design** - Generate positive test cases, negative test cases, boundary value tests, equivalence class tests
5. **Mock Strategy Planning** - Identify external dependencies, design mock implementations, create test data factories, optimize test isolation
6. **Coverage Optimization** - Ensure path coverage, optimize test efficiency, eliminate redundancy, maximize testing value
**Advanced Features**: Automatic edge case discovery, intelligent input generation, test data synthesis, coverage gap analysis, performance test generation.
**Quality Assurance**: Test maintainability, execution performance, assertion quality, debugging effectiveness.
**Output**: Comprehensive test case suite with optimized coverage, intelligent mocking, proper assertions, and maintenance guidelines.
© davila7 · MIT · davila7/claude-code-templates