---
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
```bash
# 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)
```bash
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)
```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)
```json
{
"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
```bash
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.*