TestGenEval: A Real World Unit Test Generation and Test Completion Benchmark

Kush Jain, Gabriel Synnaeve, Baptiste Rozière · DOI

Abstract

TestGenEval is a large-scale benchmark designed to evaluate Large Language Models (LLMs) on real-world software testing tasks rather than isolated code snippets. Utilizing 1,210 file pairs from prominent Python repositories, the benchmark tasks models with full test suite generation and test completion. By employing rigorous metrics such as line coverage and mutation scores, TestGenEval provides a more accurate assessment of a model's ability to produce effective, bug-catching tests in complex environments.

Introduction

While LLMs have demonstrated proficiency in solving isolated coding puzzles, their performance often degrades when applied to complex, real-world codebases. Most existing benchmarks focus on code authoring—writing single functions from prompts. However, professional software engineering involves significant effort in software testing. Existing test generation benchmarks are often limited by small scales, synthetic problems, or weak evaluation metrics like pass@k. A "passing" test is insufficient if it fails to exercise the code (coverage) or detect regressions (mutation score). TestGenEval addresses these gaps by providing a standard for both full suite generation and test completion in realistic settings.

Methodology

The researchers developed a robust pipeline to transform the SWEBench dataset into a specialized testing benchmark. This process involved three main stages: environment containerization, test pair extraction, and rigorous filtering.

Overview of the TestGenEval evaluation workflow, showing the transition from source code to LLM-generated tests and subsequent evaluation via coverage and mutation analysis.

Benchmark Construction Pipeline

The construction of TestGenEval followed a structured approach to ensure data quality and executability:

  1. Environment Setup: Docker images for 11 major Python repositories (e.g., django, matplotlib) were utilized to ensure all dependencies were met for test execution.
  2. Instrumentation: Tools were integrated to measure line coverage and mutation scores. Mutation scoring involves injecting "synthetic bugs" (mutants) into the source code to verify if generated tests can detect them.
  3. Task Definition: Two primary tasks were established: Full Suite Generation (generating a test file from scratch) and Test Completion (adding the next logical test case to an existing file).
The three-step pipeline used to create the TestGenEval benchmark: modifying SWEBench images, extracting test file pairs, and filtering for quality.

Dataset Characteristics

TestGenEval comprises 68,647 tests derived from 1,210 unique code-test file pairs across 11 major Python projects. Unlike older benchmarks with 10-20 line snippets, source files in TestGenEval average 1,157 lines of code, presenting significant architectural complexity. For researchers with limited resources, a "Lite" version containing 160 statistically representative file pairs is also provided.

Key Insights and Analysis

Evaluation across various models revealed several critical findings:

  • The Execution Reasoning Barrier: Models often struggle with "Execution Reasoning"—the ability to mentally simulate complex logic to predict correct outputs. This frequently results in assertion errors despite syntactically correct code.
  • Coverage vs. Quality: While models can achieve decent code coverage by simply invoking functions, their mutation scores often remain low. This indicates that while the code is "touched," it is not being rigorously "tested."
  • Importance of Context: In test completion tasks, providing the model with the existing test suite significantly enhances performance by allowing it to adapt to the project's specific style and setup requirements.
  • Performance Gap: Even state-of-the-art models like GPT-4o only achieved 35.2% average coverage on full generation tasks, highlighting a substantial gap between AI capabilities and human-level software engineering requirements.

Results

The evaluation included models ranging from 7B to 405B parameters. GPT-4o emerged as the top performer in full suite generation (35.2% coverage, 18.8% mutation score). Among open-source models, Llama 3.1 405B showed competitive coverage (35.0%), while Codestral 22B demonstrated exceptional efficiency in test completion tasks. Notably, there is a significant performance drop when moving from self-contained puzzles to real-world repositories, where even top models struggle to exceed 40% coverage.

Conclusion and Future Work

TestGenEval highlights the current limitations of LLMs in real-world software testing, particularly regarding execution reasoning and test quality. Future work will explore "agentic" baselines where models can iteratively fix tests based on execution feedback. Additionally, expanding the benchmark to include languages beyond Python, such as Java or C++, remains a priority for broader applicability in the software engineering domain.

Summary updated

BibTeX
@inproceedings{jain2025testgeneval,
  author = {Kush Jain and Gabriel Synnaeve and Baptiste Rozière},
  title = {{TestGenEval: A Real World Unit Test Generation and Test Completion Benchmark}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=7o6SG5gVev},
}
Figure