Published July 1, 2026 | Version v1

MockAgent: Multi-Agent Mock Generation for LLM-Based Unit Test Generation

Authors/Creators

Description

# Introduction

This is the replication package for the paper "MockAgent: Multi-Agent Mock Generation for Python Unit Testing".

This package is prepared for reproducing the main MockAgent experiment. Baselines and ablation studies are not included.

## Task Definition

Given a focal method, repository context, mock knowledge, and retrieved examples, MockAgent generates a complete pytest test method with mock setup. The generated test is evaluated by textual similarity, target hit, mock-aware precision/recall, and executable coverage metrics.

# Setup

Install Python dependencies:

```bash
pip install -r requirement.txt
```

Set API keys for the models you want to run:

```bash
export DASHSCOPE_API_KEY="YOUR_QWEN_DASHSCOPE_API_KEY"
export DASHSCOPE_DEEPSEEK_API_KEY="YOUR_DEEPSEEK_BAILIAN_API_KEY"
export GPT_API_KEY="YOUR_XSEE_API_KEY"
```

The benchmark repositories and their virtual environments are not distributed in this package. Before running the experiment, point `WORKSPACE_PROJECTS_ROOT` to your prepared workspace:

```bash
export WORKSPACE_PROJECTS_ROOT=/path/to/workspace_projects
```

The workspace should contain the project checkouts and matching `venv_*` environments used for executing generated pytest tests.

# Package Layout

```text
mockagent_rq_generation_only_qwen_coverage.py
run_main_experiments.sh
dataset/
mock_knowledge/
parser/
result/
```

- `mockagent_rq_generation.py` is the main experiment runner. The Qwen, DeepSeek, and GPT-5.2 experiments all call this same runner with different `--model`, `--base-url`, and `--api-key` values.
- `run_main_experiments.sh` launches the three main-model experiments.
- `mock_knowledge/` contains the mock guideline, API notes, and tool/function notes used by MockAgent.
- `parser/` contains parser-related dependency notes for syntax/code parsing used by the evaluation pipeline, such as AST/parser-based scoring and CodeBLEU-related components. It is not a separate model or experiment.

# Dataset

The dataset directory contains three files:

```text
dataset/clean_final_benchmark.json
dataset/train_mock_rag_590.json
dataset/cleaned_benchmark.json
```

- `clean_final_benchmark.json` is the main experiment test/evaluation set. The reported main experiment uses the `all` evaluation split over 308 samples from this file.
- `train_mock_rag_590.json` is the training/RAG example pool used for retrieval. Retrieved examples are selected from this file with `--top-k-examples 3` and `--retrieval-method curated_call_tfidf`.
- `cleaned_benchmark.json` is the cleaned overall benchmark corpus. It is included for completeness and traceability, but it is not the direct evaluation input for the reported main experiment.

Files

dataset.zip

Files (127.7 MB)

Name Size
md5:e2aa757109c61e8af3c680e414fdd157
5.7 MB Preview Download
md5:6cd969578a476de08baf1dccd5785a38
4.9 kB Preview Download
md5:ef202546ea5005cc196080bef72f400a
112.4 kB Download
md5:669da0a5cd13abebe9792e8fde953d2e
1.9 kB Preview Download
md5:4fe4023ddf16173b4ec599f0413799fc
7.3 kB Preview Download
md5:7dcfd3d896e2fdc00eb2666ae4d27e07
121.9 MB Preview Download
md5:3901c9e1a3484b9de4350b03829a0492
2.5 kB Download