🚀 TestGen AI
The Autonomous QA Agent from Your CLI
TestGen AI is a CLI tool that automatically generates, runs, and reports on test suites for your code using LLMs. Point it at a directory, set an API key, and let it handle the rest.
📦 Installation
Recommended: Use a virtual environment:
python -m venv testgen-env
# Activate it:
# Windows:
testgen-env\Scripts\activate
# macOS/Linux:
source testgen-env/bin/activate
# Install
pip install testgen-ai
Or install globally:
pip install testgen-ai
Verify:
testgen --version
That's it! Everything is configured automatically. On Windows, the first run will set up your system PATH automatically.
⚡ Quick Start
1. Set your API key (one-time)
# Google Gemini (default — has a free tier)
testgen config set GEMINI_API_KEY AIza...
# OpenAI
testgen config set OPENAI_API_KEY sk-...
# Anthropic / Claude
testgen config set ANTHROPIC_API_KEY sk-ant-...
# Ollama (local, no key needed)
testgen config set LLM_PROVIDER ollama
Keys are saved globally to ~/.testgen/.env and apply to every project automatically.
2. Generate tests
testgen generate ./src
3. Run tests
testgen test
4. Generate a report
testgen report
5. Or do everything in one shot
testgen auto ./src
✨ Features
- 🤖 AI-Powered Generation — Uses GPT-4, Claude, Gemini, or local Ollama to write real test cases, not boilerplate
- 🌍 14 Languages — Python, JavaScript, TypeScript, Go, Rust, Java, C#, Ruby, PHP, Swift, Kotlin, C++, HTML, CSS
- 👀 Watch Mode — Detects file saves and regenerates tests in real time (
--watch) - 📊 Terminal Dashboard — Color-coded test matrix with pass/fail/skip/duration per test
- 📈 HTML Reports — Professional reports with metrics, coverage insights, and execution distributions
- ⚡ Smart Context — AST-based extraction sends only relevant code to the LLM, keeping token costs low
- 🔄 One-command Workflow —
testgen autoruns the full generate → execute → report pipeline
🎯 The AGER Architecture
TestGen AI operates on a 4-step loop:
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Analyze │────▶│ Generate │────▶│ Execute │────▶│ Report │
│ (Scanner)│ │ (Brain) │ │ (Runner) │ │ (Visuals)│
└──────────┘ └──────────┘ └──────────┘ └──────────┘
| Phase | What happens |
|---|---|
| Analyze | Scans your directory, extracts function signatures and docstrings to build minimal context |
| Generate | Sends context to your LLM and receives executable test code |
| Execute | Runs the generated tests via the appropriate framework (pytest, Jest, cargo test, etc.) |
| Report | Renders a live terminal matrix and compiles an HTML report |
🎨 CLI Commands
| Command | What it does |
|---|---|
testgen generate <path> |
Generate tests for all source files in <path> |
testgen generate <path> --watch |
Watch mode — regenerate on every save |
testgen test |
Run all generated tests |
testgen test --verbose |
Run with full output |
testgen report |
Build an HTML test report |
testgen auto <path> |
Full pipeline: generate → test → report |
testgen config set KEY VALUE |
Save a config value globally |
testgen config show |
Print current global config |
📊 Terminal Output
╭─ ✅ Workflow Complete ────────────────────────╮
│ All Phases Complete! │
│ │
│ Summary: │
│ • Files Scanned: 5 │
│ • Tests Generated: 5 │
│ • Tests Passed: 67 / 67 │
│ • Tests Failed: 0 │
│ • Total Duration: 85.81s │
│ • Report: Generated │
╰───────────────────────────────────────────────╯
🌍 Supported Languages
| Language | Test Framework Used |
|---|---|
| Python | pytest |
| JavaScript | Jest |
| TypeScript | Jest |
| Go | go test |
| Rust | cargo test |
| Java | JUnit |
| C# | NUnit / xUnit |
| Ruby | RSpec |
| PHP | PHPUnit |
| Swift | XCTest |
| Kotlin | JUnit |
| C++ | Google Test |
| HTML | Custom HTML validator |
| CSS | Custom CSS linter |
The target language's runtime (Node, Go, JDK, etc.) must be installed on your machine.
pip install testgen-aionly installs the TestGen AI tool itself.
⚙️ Configuration
Config can be set globally (persists across all projects):
testgen config set GEMINI_API_KEY AIza...
testgen config set LLM_MODEL gemini-2.0-flash
testgen config set LLM_PROVIDER gemini
Or per-project via a .env file in the project root (overrides global):
OPENAI_API_KEY=sk-project-key
LLM_PROVIDER=openai
LLM_MODEL=gpt-4o
TEST_OUTPUT_DIR=./tests
MAX_CONTEXT_TOKENS=8000
Supported Providers
| Provider | Key name | Default model |
|---|---|---|
| Google Gemini | GEMINI_API_KEY |
gemini-2.0-flash |
| OpenAI | OPENAI_API_KEY |
gpt-4o |
| Anthropic | ANTHROPIC_API_KEY |
claude-3-5-sonnet |
| Ollama (local) | (none) | llama3 |
🔧 Optional: Browser / UI Testing
For Playwright-based UI test generation:
pip install testgen-ai[browser]
playwright install
The playwright install step downloads browser binaries and is a one-time setup per machine.
🛠️ Technology Stack
| Component | Technology |
|---|---|
| Language | Python 3.10+ |
| CLI Framework | Typer |
| Terminal UI | Rich |
| AI Layer | LiteLLM (model-agnostic) |
| Validation | Pydantic |
| File Watching | Watchdog |
| Testing Core | pytest |
| UI Testing | Playwright (optional) |
| Reporting | Jinja2 |
🤝 Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Run tests:
pytest - Commit:
git commit -m "Add my feature" - Push:
git push origin feature/my-feature - Open a Pull Request
📚 Documentation
Full documentation: JayPatil165.github.io/TestGen-AI
📧 Contact
- Author: Jay Ajitkumar Patil
- Email: patiljay32145@gmail.com
- GitHub: @JayPatil165
- LinkedIn: jay-patil-4ab857326
- Issues: GitHub Issues
⭐ Star this repo if TestGen AI saves you time! ⭐
Made with ❤️ by developers, for developers
Metadata
Release files for testgen-ai 0.2.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| testgen_ai-0.2.6.tar.gz | 173.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| testgen_ai-0.2.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 364.5 kB
Release files / testgen_ai-0.2.6.tar.gz
| Download URL | testgen_ai-0.2.6.tar.gz |
|---|---|
| Size | 173.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d2623d042469122c5eb974c0d12a96c854b7e76998a8e95200941f5a973eca8
|
|
BLAKE2b-256 checksum How to use checksums |
b567c501c6dba559aa4aac1d44085f9a514bab94ff938b17a8ae0c4a116761c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 7, 2026.
Transparency logRelease files / testgen_ai-0.2.6-py3-none-any.whl
| Download URL | testgen_ai-0.2.6-py3-none-any.whl |
|---|---|
| Size | 191.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3cc8ee138578790aa0cafc414333c580e00dea68c1d8fb058e390a0e05216e9c
|
|
BLAKE2b-256 checksum How to use checksums |
17dbc4cf5643c2efda87b9f5e0457a63c3edef3f6d023eafefe2ee51c14d6664
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 7, 2026.
Transparency log