Skip to content

gen-tests

by rob

Developer

Generate unit tests for code with edge cases

testing unit-tests code
# gen-tests

Generate unit tests for code with edge cases

## Installation

This is a CmdForge tool. Install it from the registry:

```bash
cmdforge install gen-tests
```

## Description

`gen-tests` analyzes your code and automatically generates comprehensive unit tests, including edge cases and boundary conditions. It supports multiple testing frameworks and produces ready-to-use test files.

## Usage

Pipe your source code into `gen-tests` to generate tests:

```bash
# Generate pytest tests for a Python function
cat my_function.py | gen-tests

# Generate tests using a specific framework
cat calculator.py | gen-tests --framework unittest

# Generate tests from a file and save to output
cat src/utils.py | gen-tests > tests/test_utils.py

# Use with code from stdin
echo "def add(a, b): return a + b" | gen-tests
```

## Arguments

| Flag | Variable | Default | Description |
|------|----------|---------|-------------|
| `--framework` | `framework` | `pytest` | Testing framework to use for generated tests |

## How It Works

1. **Test Generation (Prompt Step)**: Analyzes the input code using Claude Haiku AI and generates comprehensive unit tests including:
   - Normal use cases
   - Edge cases and boundary conditions
   - Error handling scenarios
   - Framework-specific assertions and fixtures

The tool outputs test code formatted for your chosen testing framework, ready to be saved and executed.

## Dependencies

None

No reviews yet.

Issues

No issues reported for this tool.