home / skills / greyhaven-ai / claude-code-config / test-generation

This skill automatically generates thorough tests for existing code, including unit, integration, edge cases, and error handling to improve coverage.

npx playbooks add skill greyhaven-ai/claude-code-config --skill test-generation

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
1.2 KB
---
name: grey-haven-test-generation
description: "Comprehensive test suite generation with unit tests, integration tests, edge cases, and error handling. Use when generating tests for existing code, improving coverage, or creating systematic test suites. Triggers: 'generate tests', 'add tests', 'test coverage', 'write tests for', 'create test suite'."
# v2.0.43: Skills to auto-load for test generation subagents
skills:
  - grey-haven-code-style
  - grey-haven-testing-strategy
# v2.0.74: Restrict tools for test generation work
allowed-tools:
  - Read
  - Write
  - MultiEdit
  - Bash
  - Grep
  - Glob
  - TodoWrite
---

# Test Generation Skill

Comprehensive test suite generation with unit tests, integration tests, edge cases, and error handling.

## Description

Automated test generation analyzing code structure and generating thorough test coverage for existing implementations.

## What's Included

- **Examples**: Unit test generation, integration tests, edge cases
- **Reference**: Test patterns, coverage strategies
- **Templates**: Test suite templates for different frameworks

## Use When

- Need test coverage for existing code
- Improving low coverage areas
- Systematic test creation

## Related Agents

- `test-generator`

**Skill Version**: 1.0

Overview

This skill generates comprehensive test suites for Python projects, including unit tests, integration tests, edge cases, and error-handling scenarios. It analyzes existing code to produce runnable tests and templates tailored to common frameworks. Use it to raise coverage, automate systematic test creation, and standardize testing patterns across a codebase.

How this skill works

The skill parses the target code to identify functions, classes, API boundaries, and external dependencies. It generates unit tests that assert expected behavior, integration tests that exercise component interactions, and negative tests for error paths and edge cases. Output includes ready-to-run test files, mock scaffolding, and coverage-focused templates you can drop into your repository.

When to use it

  • Generating tests for an existing Python module or package
  • Improving low or inconsistent test coverage
  • Creating a consistent test suite style across projects
  • Adding edge-case and error-path coverage before releases
  • Automating test creation during refactors or API changes

Best practices

  • Run the generated tests locally and review assertions for domain correctness before merging
  • Integrate with your CI to run tests and report coverage metrics automatically
  • Customize mock and fixture templates to match project-specific dependency patterns
  • Use the templates as a starting point—refine complex scenarios or timing-sensitive integration tests manually
  • Keep generated tests small and focused to simplify debugging failures

Example use cases

  • Generate unit tests for a utility library to cover happy paths and input validation
  • Create integration tests for a service that depends on a database and external API, including mocks
  • Bulk-add tests to modules identified as having <70% coverage during a code audit
  • Produce edge-case and error-handling tests for parsing, serialization, and network failure scenarios
  • Seed a new project with test templates for pytest or unittest frameworks

FAQ

Which testing frameworks are supported?

The skill produces templates and tests compatible with common Python frameworks like pytest and unittest; you can choose the flavor when generating tests.

Can it mock external services and databases?

Yes. The generator includes mock scaffolding and fixture examples to simulate external APIs, databases, and I/O so integration tests remain deterministic.