Skip to main content

AI-powered tool to automatically generate compliant unit tests for FastAPI controllers and service layers, enforcing strict project standards.

Project description

Agtest-AI: Automated Test Generation Agent

Agtest-AI is an intelligent command-line tool and Python library that automatically generates unit tests for FastAPI-based applications. It analyzes source code (controllers and services), understands dependencies and logic, and produces complete, production-ready pytest files that align with your project’s testing standards.

Purpose

To automate the generation of realistic and maintainable FastAPI unit tests. Agtest-AI eliminates repetitive manual effort and ensures consistent, rule-compliant testing across projects.

Key Features

Automatic File Type Detection — Identifies whether the input file is a controller or service. AI-Powered Test Generation — Uses Google Gemini API to analyze source code and generate test cases. Project-Standard Compliance — Follows internal test structures, including: -Mocked DB sessions (MagicMock(spec=Session)) -Configured TestClient with middleware and dependency overrides -Exception handling for both sync and async endpoints -Separate success and failure test cases per route -Configurable Output — Control the output directory and generation parameters. -Role-Aware Prompts — Creates distinct instructions for controllers and services to ensure context-aware test generation.

Configuration

Agtest-AI supports environment-based configuration for flexible setup:-MODEL_NAME,MAX_TOKENS,TEMPERATURE,API_KEY The output directory can be modified directly in the runner configuration.

Installation pip install agtest

Usage Run the agent directly from the command line: agent-cli

You’ll be prompted to provide: File path for test generation Gemini API key Output directory Router file path (for controllers)

The generated tests will be saved as:tests_.py

Why Agtest-AI: Save hours of manual testing effort. Maintain consistent and accurate unit tests. Improve test coverage automatically.

It supports google gemini api key and paid vertion of OpenAI api key. It gives line and file coverage of above 85%. License Distributed under the MIT License. See LICENSE for details.

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

agtest-0.2.1.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

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

agtest-0.2.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file agtest-0.2.1.tar.gz.

File metadata

  • Download URL: agtest-0.2.1.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for agtest-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4359a572545b78185aa7f98598a13ab87cbaba5a35165d764074df4994b67e5d
MD5 7ce4f80cb43d90b56851b4410698f063
BLAKE2b-256 12aad35c89a9fc724c7c31a74116ef819a133efd2707b447cf484262ae7d0de4

See more details on using hashes here.

File details

Details for the file agtest-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: agtest-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for agtest-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b0475fd100db3c8e2b477a97f8ca067b37c5d8aefc5ae635bbbc5353eb10d09
MD5 66ed2b28cc1b4608a5a7d6af5574f0f8
BLAKE2b-256 04236c5598fd1d85ab026a224b465c41c6a033530e5be6ba518634e63237b66d

See more details on using hashes here.

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