Docs Overview
This page is the high-level guide to TestGen. It explains what the tool is, how to get started, the main ways to use it, and where to find the current source-of-truth docs in the repository.
TestGen is a multi-language tool for inspecting code, generating tests, validating coverage, and supporting both human and agent-driven workflows through the TUI, CLI, repo-local wrappers, and an MCP server.
Installation
Install TestGen locally, then set one provider key before generating tests.
curl -fsSL https://raw.githubusercontent.com/princepal9120/testgen/main/install.sh | bash
irm https://raw.githubusercontent.com/princepal9120/testgen/main/install.ps1 | iex
go install github.com/princepal9120/testgen-cli@latest
Compatibility note:
- GitHub repo: github.com/princepal9120/testgen
- Go module: github.com/princepal9120/testgen-cli
Configuration
Set one provider API key before generating tests. TestGen supports Anthropic, OpenAI, Gemini, and Groq.
# Choose one provider
export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."
export GEMINI_API_KEY="AIza..."
export GROQ_API_KEY="gsk_..."
- Anthropic Claude: strong default quality for many repositories
- OpenAI: common general-purpose option
- Gemini: useful when you want a Google-hosted option
- Groq: useful when low latency matters
Quick Start
Keep the workflow simple: inspect first, preview generation second, write and validate last.
1. Inspect a codebase
testgen analyze --path=./examples --cost-estimate --recursive
2. Preview generated tests without writing
testgen generate --file=./examples/python/calculator.py \
--type=unit \
--dry-run \
--emit-patch \
--output-format json
3. Generate and validate when ready
testgen generate --path=./src --recursive --type=unit --validate
4. Prefer a guided UI?
testgen tui
Usage Modes
TestGen supports four practical usage modes today:
- TUI: best for first-time human users who want a guided terminal flow
- CLI: best for local development, scripting, and CI automation
- Agent wrappers: best when coding agents should inspect dry-run artifacts before applying writes
- MCP: best when your client prefers tool calls over shell execution
Review-first Workflow
The clearest default workflow is also the safest one: analyze the repo, generate dry-run output, inspect the results, and only then write files with validation.
# 1) inspect the repo
testgen analyze --path=./src --cost-estimate
# 2) preview structured output
testgen generate --file=./src/utils.py --type=unit --dry-run --emit-patch --output-format json
# 3) write files and validate later
testgen generate --path=./src --recursive --type=unit --validate
Integrations
All current integrations rely on the same app layer and the same review-first model.
- Codex:
.codex/skills/testgen/SKILL.md - Claude Code:
.claude/commands/testgen.md - OpenCode:
.opencode/commands/testgen.md - MCP:
testgen mcpexposestestgen_generate,testgen_analyze, andtestgen_validate
Recommended safe mode for agents
testgen generate --file=./src/utils.py --type=unit --dry-run --emit-patch --output-format json
Install wrappers into another repo
./scripts/install-agent-integrations.sh /path/to/target-repo copy
Supported Languages
TestGen currently detects and generates tests for these languages:
- JavaScript / TypeScript: Jest, Vitest, Mocha
- Python: pytest, unittest
- Go: testing, testify
- Rust: cargo test
- Java: JUnit 5-oriented generation via the Java adapter