tags:
- ai-testing
- test-generation
- multi-agent
π§ͺ TestGenius AI
AI Test Case Generation Agent for QA Teams
Multi-Agent Iterative Refinement β’ Behavior Coverage Mapping β’ Mutation-Guided Testing
Not just another GPT wrapper. A 5-agent pipeline that generates, validates, and iteratively improves tests using mutation testing feedback β inspired by MuTAP (ISSTA 2023).
π― Problem
"Writing comprehensive test cases manually is time-consuming and often misses edge cases."
QA teams spend 40-60% of their time writing tests. They miss edge cases, security vulnerabilities, and integration failures. Existing AI tools (Copilot, basic GPT wrappers) do single-shot generation with no validation β producing tests that look good but don't catch real bugs.
TestGenius AI is different. It doesn't just generate β it analyzes, generates, validates, refines iteratively, and maps behavior coverage.
π§ Research-Grade Architecture (The Key Differentiator)
Inspired by: MuTAP (arxiv:2308.16557, ISSTA 2023) + HITS (ASE 2024) + Code Agents (arxiv:2406.12952)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TESTGENIUS MULTI-AGENT PIPELINE β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β INPUT (code/requirements/API spec) β
β β β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β β AGENT 1: ANALYZER β β
β β β’ AST-based complexity scoring β β
β β β’ Behavior extraction (testable behaviors) β β
β β β’ Coverage gap detection β β
β β β’ Function prioritization (complex = more tests) β β
β ββββββββββββββββββββββββ¬βββββββββββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β β AGENT 2: GENERATOR β β
β β β’ Context-rich structured prompt β β
β β β’ Behavior-guided generation (tests PER behavior) β β
β β β’ Framework-specific (pytest/Jest/Cypress) β β
β ββββββββββββββββββββββββ¬βββββββββββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β β AGENT 3: VALIDATOR β β
β β β’ Quality scoring (5 dimensions, A-D grade) β β
β β β’ Assertion density check β β
β β β’ Edge case coverage measurement β β
β β β’ Identifies WHAT'S WEAK in the tests β β
β ββββββββββββββββββββββββ¬βββββββββββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β β AGENT 4: REFINER (MuTAP-inspired loop) β β ITERATES β
β β β’ Identifies surviving mutations β until β
β β β’ Re-prompts LLM with mutation feedback β quality β₯ B β
β β β’ Strengthens weak tests automatically β β
β β β’ Adds tests that KILL surviving mutants β β
β ββββββββββββββββββββββββ¬βββββββββββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β β AGENT 5: COVERAGE MAPPER β β
β β β’ Maps tests β behaviors (which ARE tested) β β
β β β’ Shows UNTESTED behaviors (red flags) β β
β β β’ Coverage % by category (happy/edge/error/security) β β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β OUTPUT: Tests + Quality Grade + Behavior Coverage Map β
β + Refinement History + Untested Behavior Warnings β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Why this beats every other hackathon submission:
- Single-shot generators (Copilot, GPT wrappers): Generate once, no validation β produce tests that miss bugs
- TestGenius: Generate β Score β Identify weaknesses β Re-generate stronger tests β Verify coverage
β¨ 8 Novelty Features
| # | Feature | Research Basis | What It Does |
|---|---|---|---|
| 1 | π Iterative Refinement | MuTAP (ISSTA'23) | Tests improve across iterations using mutation feedback |
| 2 | π Behavior Coverage | Qodo/CodiumAI concept | Maps WHICH behaviors are tested vs untested |
| 3 | 𧬠Mutation-Guided Testing | MuTAP + EvoSuite | Identifies test gaps where mutations would survive |
| 4 | π§ Code Complexity Analysis | McCabe (1976) | AST-based cyclomatic complexity β prioritizes testing |
| 5 | π Coverage Gap Detection | Static analysis | Finds untested error paths, branches, external calls |
| 6 | π Test Quality Scoring | Test smell research | Grades tests A-D on 5 dimensions |
| 7 | π API Security Scanner | OWASP Top 10 | Detects injection points, missing auth, path traversal |
| 8 | π€ Multi-Agent Architecture | Code Agents (arxiv:2406.12952) | 5 specialized agents, not one monolithic prompt |
π Quick Start
# Backend
cd backend
pip install -r requirements.txt
cp .env.example .env # Set LLM_BASE_URL, LLM_API_KEY, LLM_MODEL
uvicorn app.main:app --reload --port 8000
# Frontend
cd frontend
npm install && npm run dev
# β http://localhost:5173
Docker (Full Stack)
cp backend/.env.example backend/.env # Set your LLM API key
docker-compose up -d
# β Backend: http://localhost:8000/docs
# β Frontend: http://localhost:3000
Custom LLM (.env)
# Works with ANY OpenAI-compatible API:
LLM_BASE_URL=https://api.groq.com/openai/v1
LLM_API_KEY=gsk_your_key
LLM_MODEL=llama-3.3-70b-versatile
Supports: Groq, Featherless, OpenAI, Together, DeepSeek, OpenRouter, Mistral, Ollama, LM Studio
π‘ API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/generate/from-requirements |
Generate from product requirements |
| POST | /api/v1/generate/from-api-spec |
Generate from OpenAPI/Swagger |
| POST | /api/v1/generate/from-code |
Generate unit tests from source code |
| POST | /api/v1/generate/from-flow |
Generate E2E tests from user flow |
| POST | /api/v1/generate/unified |
All inputs β full test suite |
| POST | /api/v1/generate/multi-agent |
π§ Multi-agent iterative pipeline |
| POST | /api/v1/generate/multi-agent/stream |
Streaming SSE pipeline |
| POST | /api/v1/analyze/behaviors |
Extract testable behaviors |
| POST | /api/v1/analyze/complexity |
AST complexity analysis |
| POST | /api/v1/analyze/security |
OWASP API security scan |
| POST | /api/v1/analyze/mutations |
Identify mutation points |
| POST | /api/v1/analyze/mutations/execute |
𧬠Run real mutation testing |
| POST | /api/v1/analyze/quality |
Score test quality (A-D) |
| POST | /api/v1/analyze/gaps |
Coverage gap detection |
| GET | /api/v1/usage |
Token usage & cost tracking |
| GET | /api/v1/frameworks |
Supported frameworks |
| GET | /api/v1/provider |
Current LLM provider info |
| GET | /health |
System health + capabilities |
π Multi-Agent Response (Example)
{
"run_id": "MAS-a7f3b2c9",
"pipeline": "multi-agent-iterative-v2",
"quality": {
"overall": 82,
"grade": "A",
"scores": {"assertions": 8, "edge_cases": 7, "error_handling": 9, "isolation": 8, "docs": 6}
},
"syntax_validation": {"valid": true, "test_count": 18, "has_assertions": true},
"behavior_coverage": {
"total_behaviors": 18,
"covered": 15,
"uncovered": 3,
"coverage_pct": 83.3
},
"mutation_testing": {
"total_mutants": 12,
"killed": 9,
"survived": 3,
"mutation_score": 75.0
},
"iterations_performed": 2,
"processing_time_ms": 4200
}
π Project Structure
testgenius-ai/
βββ backend/
β βββ app/
β β βββ main.py
β β βββ api/
β β β βββ generate.py # Standard generation endpoints
β β β βββ multi_agent_routes.py # π§ Multi-agent + analysis endpoints
β β β βββ frameworks.py
β β βββ services/
β β βββ llm_provider.py # Universal LLM (any provider)
β β βββ test_generator.py # Core generation logic
β β βββ prompt_builder.py # Structured prompts
β β βββ multi_agent_engine.py # π§ 5-agent iterative pipeline
β β βββ novelty_features.py # Complexity, mutations, security
β βββ tests/ # Pytest test suite
β βββ Dockerfile
β βββ requirements.txt
β βββ .env.example
βββ frontend/
β βββ src/
β β βββ App.tsx # Router + Error Boundary
β β βββ pages/
β β βββ LandingPage.tsx # Hero + features
β β βββ GeneratePage.tsx # Multi-tab input + output
β β βββ AnalyzePage.tsx # Deep code analysis
β β βββ HistoryPage.tsx # Previous generations
β βββ Dockerfile
β βββ package.json
βββ docker-compose.yml
βββ README.md
π Why This Wins the Hackathon
| What Judges Look For | What We Deliver |
|---|---|
| Creativity | Multi-agent iterative refinement (no other team has this) |
| Technical depth | AST parsing, real mutation execution, OWASP scanning, behavior mapping |
| AI integration | Not "call GPT and return" β 5-agent pipeline with feedback loops |
| Real-world usability | Paste code β get production-ready tests in 3 seconds |
| Research backing | Cites MuTAP (ISSTA'23), HITS (ASE'24), Code Agents (2406.12952) |
| Production quality | FastAPI + Docker + Pydantic + universal LLM + pytest suite |
What Makes This UNIQUE vs Every Other Submission:
"Other teams will call an LLM once and return whatever it outputs. We call it, VALIDATE the output, identify weaknesses using mutation analysis, then ITERATIVELY IMPROVE until quality reaches grade A β exactly like the MuTAP paper from ISSTA 2023. That's not a wrapper β that's a research-grade AI agent."
π§ͺ Running Tests
cd backend
pip install -r requirements.txt
pytest tests/ -v
π License
MIT
TestGenius AI β Not just generating tests. Generating BETTER tests, iteratively.
Research-grade quality. Production-ready deployment. Hackathon-winning novelty.