Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

test-generator

FreeRuns bundled scriptsNot checked

Generate comprehensive test boilerplate following project TDD conventions. Use when creating new tests for modules, classes, or functions. Automatically…

aiskillstoreby aiskillstore★ 509 GitHub stars

About this skill

Test Boilerplate Generator

⚠️ MANDATORY: Read Project Documentation First

BEFORE generating tests, you MUST read and understand the following project documentation:

Core Project Documentation

  1. README.md - Project overview, features, and getting started
  2. AI_DOCS/project-context.md - Tech stack, architecture, development workflow
  3. AI_DOCS/code-conventions.md - Code style, formatting, best practices (especially for tests)
  4. AI_DOCS/tdd-workflow.md - TDD process, testing standards, coverage requirements (CRITICAL)

Session Context (if available)

  1. .ai-context/ACTIVE_TASKS.md - Current tasks and priorities
  2. .ai-context/CONVENTIONS.md - Project-specific conventions
  3. .ai-context/RECENT_DECISIONS.md - Recent architectural decisions
  4. .ai-context/LAST_SESSION_SUMMARY.md - Previous session summary

Additional AI Documentation

  1. AI_DOCS/ai-tools.md - Session management workflow
  2. AI_DOCS/ai-skills.md - Other specialized skills/agents available

Why This Matters

  • Testing Standards: Follow project-specific test structure and conventions
  • TDD Patterns: Use AAA pattern, proper fixtures, and parametrization
  • Code Quality: Generate tests with type hints, docstrings, proper imports
  • Mock Guidelines: Understand when to mock vs. use real code
  • Coverage Goals: Generate tests that help reach 80%+ coverage

After reading these files, proceed with your test generation task below.


Overview

Automatically generate comprehensive test boilerplate that follows this project's strict TDD and quality standards.

When to Use

  • Creating tests for a new module, class, or function
  • Starting TDD workflow (write tests FIRST!)
  • Need test templates with proper structure
  • Want parametrized test examples
  • Creating test fixtures

What This Skill Generates

✅ Test files with proper imports and structure ✅ Test classes organized by functionality ✅ Parametrized test templates ✅ AAA pattern (Arrange-Act-Assert) structure ✅ Complete type hints ✅ Google-style docstrings ✅ Fixture templates (when needed)

Usage Examples

Generate Tests for a Module

# User provides source file
generate tests for src/python_modern_template/validators.py

Output: Creates tests/test_validators.py with:

  • Test class for each function/class
  • Parametrized test cases
  • Edge case test templates
  • Proper imports and structure

Generate Tests for a Specific Function

# User describes the function
generate tests for validate_email function that checks email format

Output: Creates test class with:

  • Basic functionality tests
  • Edge cases (empty, invalid format, special characters)
  • Parametrized test cases
  • Error handling tests

Generate Fixture Template

# User needs test fixtures
generate pytest fixture for database connection

Output: Creates conftest.py entry with proper fixture structure

Step-by-Step Process

Step 1: Analyze Source Code

If source file provided:

  1. Read the source file
  2. Identify all public functions and classes
  3. Analyze function signatures (parameters, return types)
  4. Identify error cases (raises clauses)

If described by user:

  1. Extract function/class name
  2. Understand parameters and return type
  3. Identify test scenarios from description

Step 2: Choose Template

Select appropriate template from templates/:

  • test_function.py - Simple function tests
  • test_class.py - Class with methods tests
  • test_parametrized.py - Data-driven tests
  • test_async.py - Async function tests
  • test_exception.py - Error handling tests
  • conftest_fixture.py - Pytest fixtures

Step 3: Generate Test Code

Use templates from .claude/skills/test-generator/templates/ directory.

Template Variables:

  • {module_name} - Source module name
  • {class_name} - Class being tested
  • {function_name} - Function being tested
  • {test_class_name} - Generated test class name
  • {import_path} - Full import path
  • {param_names} - Function parameters
  • {return_type} - Function return type

Step 4: Add Test Cases

Generate test cases for:

  1. Happy path - Normal successful execution
  2. Edge cases - Boundary values, empty inputs, None values
  3. Error cases - Invalid inputs, exceptions
  4. Parametrized cases - Multiple input combinations

Step 5: Format and Save

  1. Apply proper formatting (Black, isort)
  2. Ensure type hints and docstrings
  3. Save to appropriate test file
  4. Display summary of generated tests

Templates Reference

Template: Simple Function Test

File: templates/test_function.py

"""Tests for {module_name}.{function_name}."""

from __future__ import annotations

import pytest

from {import_path} import {function_name}


class Test{FunctionNameCamelCase}:
    """Test cases for {function_name}."""

    def test_{function_name}_basic(self) -> None:
        """Test basic functionality of {function_
Full SKILL.md on GitHub

Install test-generator in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

skill-report.jsontemplates/conftest_fixture.pytemplates/test_async.pytemplates/test_class.pytemplates/test_function.pytemplates/test_parametrized.py

FAQ

What does the test-generator skill do?

Generate comprehensive test boilerplate following project TDD conventions. Use when creating new tests for modules, classes, or functions. Automatically creates tests with proper structure, type hints, docstrings, and AAA pattern.

How do I install the test-generator skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the test-generator skill run scripts?

Yes, this skill bundles executable scripts. Review the source before installing.

Related skills

Compare test-generator with