The problem
Writing unit tests is slow, and teams rarely know which files deserve tests first. General code assistants write tests that ignore a team’s own conventions, and nothing tells you where defects are most likely. TestPilot was our SER 594 course project at Arizona State University: generate tests that follow a team’s coding standards, and point at the files most worth testing.
How it works
Generates pytest, Jest and JUnit tests and ranks defect-prone files in public GitHub repositories. It retrieves the five most relevant coding-standard chunks first, drafts the tests against them, and an LLM critique loop regenerates anything scoring below 0.6.
- 1Read repositoryA repository comes in.
- 2Retrieve coding standardsThe five most relevant coding-standard chunks are retrieved first.
- 3Draft testsTests are drafted against those standards.
- 4Critique gateAn LLM critique scores each draft. Anything below 0.6 is sent back.
- 5Keep testsDrafts that pass the critique are kept.
What I built
I led the AI pipeline, the model integration and the backend. Coding standards are split into chunks, embedded with all-MiniLM-L6-v2 and stored in pgvector. For each request the five closest chunks go into a structured prompt, and a local Qwen Coder 7B model, served by Ollama on a Cloud Run GPU, streams the tests back as they are written.
A second pass scores each result for correctness, assertion quality, edge-case coverage and readability. Anything below 0.6 is regenerated with the critique as feedback.
The defect heatmap scans a public GitHub repository with PyDriller and Radon and ranks files with a Random Forest. I trained that model and fine-tuned the generator with QLoRA on 10,000 Methods2Test pairs, keeping the training, validation and test splits separate.
Measured results
| Evaluation | Result | Limitation |
|---|---|---|
| Defect prediction | Precision 0.39, recall 0.29, F1 0.34 and ROC-AUC 0.66 on 6,052 Java files | Beats chance, but is for ranking where to look first, not for deciding |
| Standards retrieval | Precision at 5 of 0.375 and recall at 5 of 0.94 over 8 labelled queries | Measured with TF-IDF as a stand-in for pgvector; some irrelevant standards reach the top five |
Measurements and limitations are reported together.