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.3.tar.gz (14.4 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.3-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agtest-0.2.3.tar.gz
  • Upload date:
  • Size: 14.4 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.3.tar.gz
Algorithm Hash digest
SHA256 ddee8fd7968365b64568125e6e67d248d9d140fb537ca6ff40a375df68eb4266
MD5 a9f1134ad312875ddabbc9fefceceb68
BLAKE2b-256 fa5f8f6fe253a7b6cddf9542db6e615ba0bcd9e4c31190981efb84391d3ef9fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agtest-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 14.7 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5d7eef7b7d52244a544cbe96a5796d63f60cbb0ba3138e2fe4bb8033f597c2d7
MD5 6687f1887af2addc4af8810b32fa24ee
BLAKE2b-256 8482de250eb3e0bbfb389732da80d644f7a0f32877dc9343bd5cf5d4b8467f2d

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