Skip to main content
command CX Codex

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

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --command testing/generate-test-cases
Open on GitHub

What 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.ts with 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-cases

2Manually: put the files in place

.claude/commands/generate-test-cases.md

Call it with /generate-test-cases. For all projects use ~/.claude/commands/

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

Similar slash commands

All slash commands for Testing and QA →

From the same set745

The whole set →
setup-development-environment setup-development-environment — a slash command that builds out a dev environment: runtimes, tooling, build setup, linters, configs. Handy when you spin up a project on a fresh machine. CX Codex +1 651installs unreal-engine-developer The unreal-engine-developer subagent supports Unreal Engine work in C++ and Blueprints, from project architecture to rendering, multiplayer, and performance profiling. CX Codex 650installs url-context-validator url-context-validator is a Claude Code subagent that checks URLs for technical issues and compares destinations with surrounding text. It supports link audits in docs and web copy. CX Codex 640installs test-coverage test-coverage — a Claude Code command that measures code coverage and identifies untested paths. Run it manually with flags like --line, --branch, --function or --report. CX Codex +1 637installs mcp-registry-navigator The mcp-registry-navigator subagent finds MCP servers, reviews their capabilities, and prepares integration configs. Use it when you need to discover or publish servers. CX Codex 628installs brightdata-local-search brightdata-local-search spins up a local search pipeline on Bright Data's SERP API: query expansion, SERP retrieval, RRF reranking. CX Codex +1 625installs resume resume recovers task orchestration context in Claude Code after a dropped session or project switch. CX Codex +1 622installs cloud-migration-specialist cloud-migration-specialist — a subagent that maps application workloads to cloud platforms, plans cutover waves, and configures containers. Built for migrations to AWS, Azure, or GCP. CX Codex 617installs

Project sponsors

Companies that keep this analytics open