MultiFileTest: A Multi-File-Level LLM Unit Test Generation Benchmark and Impact of Error Fixing Mechanisms

Yibo Wang, Congying Xia, Wenting Zhao, Jiangshu Du, Chunyu Miao, Zhongfen Deng, Philip S. Yu, Chen Xing

TL;DR

While Large Language Models (LLMs) excel at generating single-file code snippets, real-world software development relies on complex, multi-file codebases. This paper introduces MultiFileTest, a novel benchmark designed to evaluate LLM unit test generation across multi-file projects in Python, Java, and JavaScript. The study reveals that while frontier LLMs struggle with cross-file dependencies, implementing basic error-fixing mechanisms dramatically unlocks their hidden testing capabilities.

What Problem Does This Paper Address?

Automated unit test generation saves developers significant time, and LLMs have recently supercharged this process. However, existing evaluation benchmarks (like HumanEval or ClassEval) primarily focus on isolated functions or single classes within a single file.

In the real world, code doesn't live in a vacuum. A function in FileA.py might import a class from FileB.py, which in turn depends on a utility module in FileC.py. To write an effective unit test, an LLM must understand these intricate cross-file dependencies and properly configure the test environment. This paper bridges the gap between simplistic benchmarks and realistic software engineering by providing a rigorous framework to evaluate how well LLMs handle multi-file reasoning.

Methods

The authors established a standardized pipeline to evaluate 11 frontier LLMs (including GPT-4-Turbo, GPT-o1, Gemini-3.0-Pro, and Claude-3.5-Sonnet) across three distinct testing scenarios:

  1. Scenario 1: Vanilla Unit Tests: The baseline scenario where the entire multi-file codebase is fed into the LLM with a language-specific prompt, and the raw generated tests are executed directly.
  2. Scenario 2: Manual Fixing: Human experts step in to resolve basic "mechanical" errors (such as incorrect import paths or missing boilerplate mocks) without altering the core test logic. This isolates the LLM's deep testing capability from shallow syntax failures.
  3. Scenario 3: LLM Self-fixing: The LLM is provided with the test framework's error messages and its own previous response, then asked to fix the code in a single-turn conversation.

The evaluation process is illustrated below:

Overview of the unit test generation process.

To measure performance, the authors tracked Executability Rate (ER), Correctness Rate (CR), Line Coverage (LC), and Branch Coverage (BC). They also introduced a Unique Contribution metric to evaluate test efficiency by calculating the non-overlapping coverage provided by each individual test case.

Datasets

The authors introduced the MultiFileTest benchmark, which consists of 60 high-quality, self-contained multi-file projects curated from GitHub (20 projects each for Python, Java, and JavaScript).

To ensure fair evaluation across models with varying context windows, each project was filtered to be moderate-sized (2–15 files and under 1,600 lines of code). Crucially, every repository was verified to enforce cross-file dependencies.

Data Statistics for MultiFileTest

Key Insights and Ideas

  • Shallow Errors Mask Deep Capabilities: In vanilla generation, many advanced models scored poorly because of simple mistakes like hallucinating an import path or missing a package declaration. When humans fixed these minor mechanical issues, the models' underlying test logic was revealed to be surprisingly robust.
  • Java is the Ultimate Boss: Java proved to be the most challenging language for LLMs due to its strict syntax and heavy reliance on complex mocking frameworks (like Mockito). Multiple open-source models completely failed to generate a single executable Java test suite in the vanilla setting.
  • Quantity $\neq$ Quality: Some models (like Gemini-2.0-Flash) generated a massive number of test cases but achieved lower code coverage. The "Unique Contribution" analysis showed that LLMs frequently write highly redundant tests, prioritizing volume over diverse code path exploration.
  • The Self-Fixing Gap: While closed-source models showed a clear capacity for self-fixing when handed an error log, open-source models struggled significantly, often generating textual explanations instead of corrected code.

Key Results

  • Vanilla Performance: Gemini-3.0-Pro emerged as the top overall performer, leading in Python (77% Correctness Rate) and Java (62% Correctness Rate). Meanwhile, GPT-o1 dominated JavaScript with an impressive 87% Correctness Rate and 95% Executability Rate.
  • The Power of a Quick Fix: Manual intervention triggered massive performance leaps. For instance, fixing basic setup errors in Java brought every single model up to a 100% Executability Rate, which subsequently unlocked huge gains in line and branch coverage.
  • Self-Fixing Potential: When allowed to self-fix, Gemini-3.0-Pro pushed its Python correctness up to 91%. However, across most models, automated self-fixing still lagged behind human-level fixes.
Evaluation Results after Self-fixing

Limitations and Future Work

The primary limitation of MultiFileTest is its scale: projects are capped at roughly 1,600 lines of code to prevent context window truncation. Consequently, it does not evaluate an LLM's ability to navigate massive, production-scale enterprise repositories that require advanced retrieval-augmented generation (RAG) or hierarchical code decomposition. Additionally, the benchmark is currently limited to three languages, excluding other prominent systems languages like C and C#.

Future work will focus on expanding the benchmark to larger codebases and exploring multi-turn, agentic workflows for automated test generation.

Summary updated

BibTeX
@inproceedings{wang2026multifiletest,
  author = {Yibo Wang and Congying Xia and Wenting Zhao and Jiangshu Du and Chunyu Miao and Zhongfen Deng and Philip S. Yu and Chen Xing},
  title = {{MultiFileTest: A Multi-File-Level LLM Unit Test Generation Benchmark and Impact of Error Fixing Mechanisms}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.findings-acl.1403},
}
Figure