We provide TestAgent as a VS Code extension that integrates the full multi-agent workflow into everyday development. A demo video is available here:
TestAgent_Plugin_Demo.mp4
TestAgent is a multi-agent LLM framework for repository-level unit test generation grounded in a Code Knowledge Graph (CKG). It organizes test development into three phases and assigns each phase to a specialized agent:
- Planner: analyzes the focal method and derives test points (behavioral objectives).
- Generator: synthesizes concrete tests, compiles and executes them, and iterates on failures.
- Reviewer: evaluates test adequacy across test points and decides whether to accept, revise, or extend.
TestAgent uses a three-layer architecture:
- CKG layer: stores repository-level entities and relationships (classes, methods, dependencies, calls, tests).
- Tool layer: provides deterministic operations (compile, execute, coverage, mutation) and retrieval/update APIs over the CKG.
- Agent layer: coordinates planning, generation, and review using tool-mediated interactions.
Empirical results from the paper show strong effectiveness on real-world Java projects: 99.11% compilation success, 97.46% execution success, 92.34% line coverage, 90.24% branch coverage, and 83.69% mutation score. TestAgent also detects 154 real bugs with 92.22% precision. The framework remains effective across different LLM backends (e.g., GPT-4o, DeepSeek-V3, Qwen3-30B).
backend/- FastAPI service implementing the multi-agent workflow and tool layervscode-extension/- VS Code extension for interactive usage
- Java 11+ (required for CKG construction and test execution)
- Neo4j 5.x (CKG storage)
- Python 3.10+ (backend)
- Node.js 20+ (extension development)
- VS Code 1.99+
- Install Neo4j and start a local instance.
- Verify connectivity in Neo4j Browser:
http://localhost:7474. - Note your credentials (default user is
neo4j).
Edit backend/Config.py and set the following fields:
OPENAI_API_BASEOPENAI_API_KEYCKGConstruction_Jar_Path(path toCKGConstruction-1.0-SNAPSHOT.jar)- Optional:
RECURSION_LIMIT,Enable_Native_Function_Call,Limit_Retrieve_Test_Case
pip install -r backend/requirements.txtpython backend/start_server.pyThe API defaults to http://localhost:8000 and exposes both task-based and streaming endpoints.
Edit vscode-extension/config/userConfig.json (or use the Settings UI after launching the extension):
{
"neo4j": {
"serverUrl": "bolt://localhost:7687",
"serverUser": "neo4j",
"serverPassword": "your-neo4j-password"
},
"testAgent": {
"recursionLimit": 50,
"openaiApiBase": "https://api.openai.com/v1",
"openaiApiKey": "your-openai-api-key",
"enableNativeFunctionCall": false,
"limitRetrieveTestCase": false,
"ckgConstructionJarPath": "/path/to/CKGConstruction-1.0-SNAPSHOT.jar",
"testGenerationApiUrl": "http://localhost:8000/generate_test_case_stream",
"testGenerationLimit": 50
}
}We provide a prebuilt VSIX package in vscode-extension/. Steps 8 and 9 are optional and only required if you want to build or package the extension yourself.
cd vscode-extension
npm install
npm run compileLaunch the extension in VS Code (Run and Debug -> "Run Extension") or use code --extensionDevelopmentPath=....
cd vscode-extension
npx @vscode/vsce packageThe VSIX package is generated in vscode-extension/ (for example: testagent-0.1.0.vsix).
This walkthrough mirrors the demonstration scenario described in the paper.
- Open a target Java repository in VS Code.
- Launch TestAgent from the Activity Bar.
- Configure runtime settings (Neo4j connection, LLM API base/key, CKG JAR path, backend endpoint).
- Build the Code Knowledge Graph (CKG):
- Trigger "Generate Knowledge Graph".
- The tool performs static analysis and stores entities and relations in Neo4j.
- Inspect the CKG visualization:
- Use "Show Knowledge Graph" to explore classes, methods, and dependencies.
- Select focal methods:
- Browse the testable method list in the sidebar.
- Select one or multiple methods as focal targets.
- Generate tests (Planner -> Generator -> Reviewer):
- The Planner derives test points from method behavior and context retrieved from the CKG.
- The Generator synthesizes tests and executes them, using tool feedback to refine failures.
- The Reviewer evaluates adequacy and decides whether to accept or request refinements.
- Monitor live progress:
- Streamed logs and step updates show the agent workflow state, intermediate outputs, and diagnostics.
- Review results:
- Test cases are returned with execution summaries, coverage metrics, and mutation results.
- Inject accepted tests:
- Use "Inject Test Case" (single) or "Inject All Test Cases" (batch) to write tests into
src/test.
- Iterate or extend:
- Refine test points, regenerate as needed, and re-run evaluation for improved coverage.
- Backend workflow:
backend/README.md - Extension workflow:
vscode-extension/README.md
MIT License. See LICENSE.