TestGuard AI - Catch What Your Tests Could Not TestGuard AI is an AI-assisted testing tool for developers developed as an MVP during the IBM Bob 2.0 Hackathon. This tool addresses one of the biggest issues developers face – writing tests for only the "happy path" scenarios, where there might be edge and boundary cases which are found as production issues down the road. TestGuard AI solves this issue by analyzing Python code (including pytest tests if any) and generating test cases on its own. Working The user pastes Python source code and optionally existing pytest test case(s). Then TestGuard AI performs a two-step process: Static AST Analysis - In this step, the backend using Python's built-in ast library analyzes function definitions, if-elif-else statement tree structure, identifies boundary conditions (numeric comparison), cross-referencing between existing tests and the source code function to identify untested branches, and edge cases from argument name inference (age, price, discount). AI-Aided Analysis — The AST data, source code, and current tests are submitted to Google Gemini (gemini-flash-lite-latest) through the JSON-mode prompt. The instructions tell Gemini not to duplicate the results of static analysis, but to produce new observations, expressing them in conservative terms ("possible missing tests"). The findings are presented on the dashboard including the risk-level badge, possible missing test scenarios, and edge case scenarios marked. Then the user is provided with the option to create the full pytest functions by clicking the button — either created by Gemini or by the fallback approach not relying on the API key. Main Design Decision: AST First, AI Second One of the main design decisions was to make the AST analysis completely independent from the AI layer, thus making the application runnable even without the Gemini API key. In the API response, there is an ai_available flag, which is used in the frontend to display "Static Analysis Only" or "AI Enhanced". Architecture & Tech Stack Frontend: React 19 + Vite + Tailwind CSS 3, with a 3 screens flow (input code → results → generate tests), using React Router's location.state for state management instead of Redux to make it simple. Backend: FastAPI (Python 3.14) + Uvicorn, with /analyze and /generate-tests endpoints, using Pydantic models for data validation. AI integration: Google Gemini via google-genai SDK, with response_mime_type = application/json for structure-safe responses. Dev tools: Vite proxy to avoid CORS problems locally. Generated With IBM Bob 2.0 All project parts from planning, Pydantic models, AST engine, AI integration, pytest generator, React frontend code, up to debugging were generated, reviewed, and improved using IBM Bob 2.0 following 11 stages of work described in HACKATHON_NOTES.md, including an OpenAI-to-Google SDK replacement midway. Features & Limitations This MVP supports Python and pytest only, doesn't save any session results, needs an API key for Google Gemine to access AI functionality (but static code analysis works without API keys), and generates tests with some imports that need to be corrected manually. Demo Flow: Install the application → click on "Try Example" → "Analyze Code" for risk level and test absence → "Generate Tests" for the pytest code → copy in one click.
Category tags: