CClaude Code Catalog
All Skills

Test Generator

CodingIntermediate

Analyzes specified functions or modules to auto-generate test code covering all code paths and edge cases.

Trigger/test [file]
Frequency2-3x/week

Developer who keeps putting off writing tests? Run /test utils.ts once to get a complete test suite

TestingAutomationQuality

How It Works

Run /test [file] -> detect test framework
Phase 1: 2 analyses in parallel
path-analyze
Analyze code paths
edge-detect
Extract edge cases
Generate test code -> auto-run verification
Test file covering all paths

Skill Code

# Test Writer Skill ## Trigger: /test [file or function] When invoked: 1. Detect test framework: - Check package.json for jest, vitest, mocha, pytest - Find existing test files for pattern reference 2. Analyze target code: - All code paths (if/else, switch, try/catch) - Input parameter types and ranges - Return value types - Side effects and dependencies 3. Generate test cases: - ✅ Happy path (normal inputs) - ❌ Error cases (invalid inputs, exceptions) - 🔲 Boundary values (0, -1, empty, null) - 🔲 Edge cases (concurrent, large data) 4. Write test file: - Follow project naming convention - Use describe/it or test blocks - Include setup and teardown if needed - Mock external dependencies 5. Run tests to verify they pass

Copy and paste into your CLAUDE.md to start using immediately.

How Test Generator Works

Test Writer reads the target file's implementation, identifies functions, edge cases, and dependencies, then generates comprehensive unit tests using your project's testing framework with proper mocks and assertions.

When to Use Test Generator

Most useful when you inherit untested code or need to quickly add test coverage before refactoring — it understands the code's behavior and generates tests that actually verify the important paths.

Key Strengths

  • Auto-detects testing framework from project configuration
  • Generates edge case tests most developers would miss
  • Produces ready-to-run tests, not just skeletons
  • Covers both happy paths and error scenarios systematically

Same Category

Coding View All

Popular in Other Categories