The Autonomous QA Agent from Your CLI - AI-powered test generation and execution
Project description
๐ 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
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ TEST EXECUTION MATRIX โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฆโโโโโโโโโโโฆโโโโโโโโโโโฆโโโโโโโโโโโโโฃ
โ Test Name โ Status โ Duration โ Details โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโฃ
โ test_user_login โ โ PASS โ 0.24s โ โ
โ test_user_registration โ โ PASS โ 0.31s โ โ
โ test_password_validation โ โ FAIL โ 0.12s โ AssertionEโฆโ
โ test_database_connection โ โ PASS โ 5.01s โ [SLOW] โ
โ test_api_endpoint_users โ โ PASS โ 0.89s โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉโโโโโโโโโโโฉโโโโโโโโโโโฉโโโโโโโโโโโโโ
Summary: 4 passed, 1 failed, 0 skipped | Total: 6.57s
๐ 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file testgen_ai-0.2.1.tar.gz.
File metadata
- Download URL: testgen_ai-0.2.1.tar.gz
- Upload date:
- Size: 169.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0040c89535d58d21573fcaa74d9c6587dda2a354d61f764714fb3329c1ab0e9
|
|
| MD5 |
d1931eda072fc23c9a5b3d6a79334615
|
|
| BLAKE2b-256 |
f692ac16f36b8c15b298924f4ce0061c9eebcd13a818af65de6bc96a7e874b81
|
Provenance
The following attestation bundles were made for testgen_ai-0.2.1.tar.gz:
Publisher:
publish.yml on JayPatil165/TestGen-AI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
testgen_ai-0.2.1.tar.gz -
Subject digest:
b0040c89535d58d21573fcaa74d9c6587dda2a354d61f764714fb3329c1ab0e9 - Sigstore transparency entry: 1096012051
- Sigstore integration time:
-
Permalink:
JayPatil165/TestGen-AI@fcbaba9a70d4c6448491fbc600b87a39715a9431 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/JayPatil165
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fcbaba9a70d4c6448491fbc600b87a39715a9431 -
Trigger Event:
push
-
Statement type:
File details
Details for the file testgen_ai-0.2.1-py3-none-any.whl.
File metadata
- Download URL: testgen_ai-0.2.1-py3-none-any.whl
- Upload date:
- Size: 187.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21ce40e1328f1b4510c17234dd5c66f4c1a6bc879e569a8d6e0e947646f252a1
|
|
| MD5 |
187dd07c2dea746d5587d711df54fd86
|
|
| BLAKE2b-256 |
1f9e50839cbf1397009febc13e8466b02e557b2e537384d4dcea3ad5c17df602
|
Provenance
The following attestation bundles were made for testgen_ai-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on JayPatil165/TestGen-AI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
testgen_ai-0.2.1-py3-none-any.whl -
Subject digest:
21ce40e1328f1b4510c17234dd5c66f4c1a6bc879e569a8d6e0e947646f252a1 - Sigstore transparency entry: 1096012072
- Sigstore integration time:
-
Permalink:
JayPatil165/TestGen-AI@fcbaba9a70d4c6448491fbc600b87a39715a9431 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/JayPatil165
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fcbaba9a70d4c6448491fbc600b87a39715a9431 -
Trigger Event:
push
-
Statement type: