
Writing thorough unit tests is one of the most time-consuming and frequently skipped steps in software development. Developers often ship code with minimal test coverage simply because writing comprehensive tests by hand takes too long. Auto Test Gen solves this by automatically generating pytest test suites for any Python function. Using AST (Abstract Syntax Tree) analysis, it inspects a function's parameters and type annotations without executing any code, then generates three categories of tests: happy-path cases, edge cases (empty lists, negative numbers, boundary values), and exception handling (invalid types, structural errors). The tool is fully generic — it does not rely on hardcoded assumptions about any specific function. This was validated by testing it against multiple unrelated functions (a missing-elements finder, an even-number counter, and a Roman numeral converter), confirming it generates relevant tests regardless of the function's internal logic. Target users are individual developers and small teams who want to increase test coverage quickly without writing tests manually — especially useful in fast-moving projects or when onboarding legacy code with no existing tests. The tool offers two interfaces: a command-line tool for quick terminal use, and a Streamlit web interface where users can upload a .py file and see generated tests and results side-by-side. Every run produces a code coverage report (via pytest-cov), giving users an immediate, measurable view of how thoroughly their function is tested — in one case, achieving 100% coverage on fully-annotated functions with zero manually written tests. A key design decision was building resilience into the AI integration: when watsonx.ai credentials are available, the tool calls IBM's granite-3-8b-instruct model to generate logic-specific tests; if the AI service is unavailable for any reason, it automatically falls back to the rule-based generator without interrupting the user's workflow — a pattern common in production-grade tools.
27 Sep 2026