Skip to main content

TestGenie

TestGenie is an automated unit test generation tool for Python that supports multiple test generation strategies, including static AST analysis, fuzz testing, feedback-directed random testing, and reinforcement learning.
Built with a modular Pipe and Filter architecture, it analyzes Python source code to extract function metadata, generates meaningful test cases, and outputs executable test suites in formats like Unittest, PyTest, or Doctest.
The system can also measure and report code coverage and safely execute tests in Docker containers.
TestGenie aims to reduce manual testing effort, improve coverage, and explore the potential of learning-based approaches for optimizing test generation.


Installation

Make sure you have Python 3.10+ and Poetry installed.

Install dependencies:

poetry install

Activate the virtual environment:

poetry shell

Running the CLI

To invoke the test generator, run:

poetry run python -m testgen.main <file_path> [options]

Required Argument:

  • <file_path>: Path to the Python module you want to analyze.

Command-Line Options

Command/Flag Description
--output, -o <path> Path to output directory for generated test files (default: ./tests)
--generate-only, -g Only generate test code, skip running tests and measuring coverage
--test-mode <mode> Set the test analysis strategy: ast (default), random, fuzz, or reinforce
--test-format <format> Set the test output format: unittest (default), pytest, or doctest
--safe Run test generation inside a Docker container for isolation and safety
--query, -q Query the database for test cases, coverage data, and test results for a specific file
--db <db_path> Path to SQLite database file (default: testgen.db)
--reinforce-mode <mode> Set mode for reinforcement learning: train (default) or collect
--visualize, -viz Visualize generated test coverage graphs using Graphviz
--debug Enable debug logging output
--log-file <path> Save logs to the specified file instead of only printing to the console

Examples

Generate and run unit tests for a Python module:

poetry run python -m testgen.main mymodule.py

Generate tests using fuzzing strategy and output to a custom directory:

poetry run python -m testgen.main mymodule.py --test-mode fuzz --output generated_tests/

Run reinforcement learning-based test generation:

poetry run python -m testgen.main mymodule.py --test-mode reinforce

Query previously generated test results from the database:

poetry run python -m testgen.main mymodule.py --query

Safely generate tests inside a Docker container:

poetry run python -m testgen.main mymodule.py --safe

Features

  • Static analysis using Python AST
  • Fuzz testing using randomized input generation
  • Feedback-directed random testing
  • Reinforcement learning-based test case optimization
  • Supports Unittest, PyTest, and Doctest formats
  • Code coverage measurement and reporting
  • Docker sandboxing for safe test execution
  • SQLite database integration for tracking tests and results
  • CLI visualization of test coverage graphs

Requirements

  • Python 3.10+
  • Poetry
  • (Optional) Docker (for safe mode execution)

Metadata

Release files for testgenie-py 0.3.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for testgenie-py 0.3.9
File Size Uploaded
testgenie_py-0.3.9.tar.gz 48.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for testgenie-py 0.3.9
File Interpreter ABI Platform
testgenie_py-0.3.9-py3-none-any.whl Python 3 none any Details

Total release size: 121.6 kB

Release files / testgenie_py-0.3.9.tar.gz

Download URL testgenie_py-0.3.9.tar.gz
Size 48.9 kB
Tags Source
SHA-256 checksum
How to use checksums
463431457db62aca7cb5a242c34633a8dc96d44bf1565614a77029378d79388c
BLAKE2b-256 checksum
How to use checksums
feb9103eac32ce54f5725b3d6e1cb4789356480cf576e14de7ede673f4500338
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.10.12 Linux/5.15.133.1-microsoft-standard-WSL2

Release files / testgenie_py-0.3.9-py3-none-any.whl

Download URL testgenie_py-0.3.9-py3-none-any.whl
Size 72.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5808a8e3414615ccc5a9bfdaa90dba0b3ec6a47b672c3b7be3f55e08de56052f
BLAKE2b-256 checksum
How to use checksums
f86ef4551a8c2d09e44d473cc882928c9e9f362343278cb1b565bbaed4f25042
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.10.12 Linux/5.15.133.1-microsoft-standard-WSL2

Release history Release notifications | RSS feed

This release

0.3.9 This release

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page