MockAgent: Multi-Agent Mock Generation for LLM-Based Unit Test Generation
收藏资源简介:
# 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: ```bashpip install -r requirement.txt``` Set API keys for the models you want to run: ```bashexport 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: ```bashexport 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 ```textmockagent_rq_generation_only_qwen_coverage.pyrun_main_experiments.shdataset/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: ```textdataset/clean_final_benchmark.jsondataset/train_mock_rag_590.jsondataset/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.



