home / skills / phodal / auto-dev / test-gen

test-gen skill

/examples/skills/test-gen

This skill generates comprehensive, maintainable unit tests for Kotlin code files, covering happy paths, edge cases, and errors with clear naming.

npx playbooks add skill phodal/auto-dev --skill test-gen

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

Files (1)
SKILL.md
594 B
---
name: test-gen
description: Generate comprehensive unit tests for code files
---

# Unit Test Generation

You are an expert at writing comprehensive, maintainable unit tests.

## Test Generation Request

$ARGUMENTS

## Guidelines

1. **Structure**: Arrange-Act-Assert pattern
2. **Coverage**: Happy path, edge cases, error cases
3. **Quality**: Independent, repeatable, fast, clear
4. **Naming**: Descriptive test names

## Test Categories

- Constructor tests
- Method behavior tests
- Exception handling tests
- Boundary condition tests
- Integration points tests

Project: $PROJECT_NAME

Overview

This skill generates comprehensive, maintainable unit tests for Kotlin code files. It produces organized test suites following Arrange-Act-Assert and targets high coverage across happy paths, edge cases, and error cases. The output emphasizes clear naming, fast execution, and independent, repeatable tests. It supports constructor, method, exception, boundary, and integration-point tests.

How this skill works

You provide the code file or signature and the skill inspects public and internal APIs to identify units to test. It synthesizes test cases that exercise constructors, methods, and interaction points, including positive flows and failure modes. Tests are organized into descriptive suites and methods with setup and teardown scaffolding as needed. The skill outputs ready-to-run Kotlin test code compatible with common test frameworks.

When to use it

  • Adding tests to legacy or untested Kotlin modules
  • Before merging significant feature work to prevent regressions
  • To harden error handling and boundary conditions
  • When adopting or enforcing test standards across a codebase
  • During test-driven development to accelerate test creation

Best practices

  • Follow Arrange-Act-Assert structure consistently in each generated test
  • Prefer small, focused tests that validate one behavior per test
  • Use descriptive, actionable test names that express expected behavior
  • Mock or stub external dependencies to keep tests fast and isolated
  • Include edge and error cases in every test suite for robust coverage

Example use cases

  • Generate constructor tests that validate default state and invalid arguments
  • Create method behavior tests covering normal flows and return values
  • Produce exception handling tests that assert thrown exceptions and messages
  • Build boundary condition tests for limits, nulls, and empty collections
  • Scaffold integration-point tests for interactions with collaborators or I/O

FAQ

Can the skill target a specific test framework?

Yes. Specify the preferred Kotlin testing framework (JUnit, Kotest, MockK) and the generated tests will follow that style.

Will generated tests run reliably in CI?

Tests are designed to be independent and fast. External I/O is mocked or isolated so suites are suitable for CI, but you should review and adapt environment-specific setup as needed.