Skip to main content

The Autonomous QA Agent from Your CLI - AI-powered test generation and execution

Project description

๐Ÿš€ TestGen AI

The Autonomous QA Agent from Your CLI

PyPI version Python 3.10+ Docs Code style: black

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 auto runs 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-ai only 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

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Make your changes
  4. Run tests: pytest
  5. Commit: git commit -m "Add my feature"
  6. Push: git push origin feature/my-feature
  7. Open a Pull Request

๐Ÿ“š Documentation

Full documentation: JayPatil165.github.io/TestGen-AI


๐Ÿ“ง Contact


โญ Star this repo if TestGen AI saves you time! โญ
Made with โค๏ธ by developers, for developers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

testgen_ai-0.2.3.tar.gz (172.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

testgen_ai-0.2.3-py3-none-any.whl (191.2 kB view details)

Uploaded Python 3

File details

Details for the file testgen_ai-0.2.3.tar.gz.

File metadata

  • Download URL: testgen_ai-0.2.3.tar.gz
  • Upload date:
  • Size: 172.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for testgen_ai-0.2.3.tar.gz
Algorithm Hash digest
SHA256 c77a77f36d74745c1e2f440dd0b3ded653df3696e93f16be8f77aa4f34930719
MD5 13990504e58eb482395c08c8ad66a5a2
BLAKE2b-256 05d26788b11bfb74f7031b67dda23e2feda18bb0c7dcc3cad3b18864fb384558

See more details on using hashes here.

Provenance

The following attestation bundles were made for testgen_ai-0.2.3.tar.gz:

Publisher: publish.yml on JayPatil165/TestGen-AI

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file testgen_ai-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: testgen_ai-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 191.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for testgen_ai-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2f53812a74aa9ede749413d61349d8a18d8dfd74e6adfef1cf79fcccfb904029
MD5 af12ce644043d0dda1b06cea4aed95cb
BLAKE2b-256 6e3b82e1cbb65f091a76b756e59987103209dbc16114844b35a25c681110e7e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for testgen_ai-0.2.3-py3-none-any.whl:

Publisher: publish.yml on JayPatil165/TestGen-AI

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page