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.1.tar.gz (169.3 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.1-py3-none-any.whl (187.6 kB view details)

Uploaded Python 3

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

Hashes for testgen_ai-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b0040c89535d58d21573fcaa74d9c6587dda2a354d61f764714fb3329c1ab0e9
MD5 d1931eda072fc23c9a5b3d6a79334615
BLAKE2b-256 f692ac16f36b8c15b298924f4ce0061c9eebcd13a818af65de6bc96a7e874b81

See more details on using hashes here.

Provenance

The following attestation bundles were made for testgen_ai-0.2.1.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.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

Hashes for testgen_ai-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21ce40e1328f1b4510c17234dd5c66f4c1a6bc879e569a8d6e0e947646f252a1
MD5 187dd07c2dea746d5587d711df54fd86
BLAKE2b-256 1f9e50839cbf1397009febc13e8466b02e557b2e537384d4dcea3ad5c17df602

See more details on using hashes here.

Provenance

The following attestation bundles were made for testgen_ai-0.2.1-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