NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

TESTEVAL: Benchmarking Large Language Models for Test Case Generation

Wenhan Wang, Chenyuan Yang, Zhijie Wang, Yuheng Huang, Zhaoyang Chu, Da Song, Lingming Zhang, An Ran Chen, Lei Ma

Introduction

Software testing is a critical yet labor-intensive phase of the development lifecycle. While Large Language Models (LLMs) have demonstrated impressive capabilities in code generation, their ability to generate effective test cases—specifically those that probe deep program logic—remains under-explored. Existing benchmarks often focus on whole-program generation or simple input/output prediction, failing to measure if a model truly understands the internal control flow required to reach complex edge cases. To address this, we present TESTEVAL, a benchmark designed to evaluate LLMs on their ability to reason through program logic to satisfy specific execution constraints.

Methodology

The TESTEVAL framework evaluates models across three tasks of increasing complexity:

  1. Overall Coverage: Maximizing the percentage of lines and branches executed by a set of generated tests.
  2. Targeted Line/Branch Coverage: Generating a specific test case to execute a pre-selected line or branch.
  3. Targeted Path Coverage: Generating an input that follows a specific sequence of multiple branches.
The TESTEVAL evaluation pipeline, from program input to test case evaluation.

The researchers introduced the cov@k metric to evaluate coverage efficiency within $k$ attempts. The dataset comprises 210 Python programs from LeetCode with high cyclomatic complexity ($\ge 10$), ensuring challenging logic. Evaluation involved 17 LLMs, utilizing techniques like two-step Chain-of-Thought (CoT) prompting to bridge the "reasoning gap."

Key Insights: The Reasoning Gap

A primary finding is the "Spray and Pray" phenomenon. While top models like GPT-4o achieve high overall coverage (often >90%), this success is frequently due to generating a high volume of diverse inputs rather than precise logical reasoning. When tasked with hitting a specific, difficult-to-reach line, performance drops significantly.

Visualizing different execution paths through a program's control flow, illustrating the complexity of targeted path coverage.

The most significant hurdle is Targeted Path Coverage. As illustrated above, following a specific execution path requires sequential reasoning about how state changes across multiple branches. This "final boss" of testing remains largely unsolved; while GPT-4o leads with 56.67% accuracy, most models struggle to map code lines back to the necessary input constraints.

Results and Performance

Commercial models currently lead the field, with GPT-4o reaching 98.65% line coverage and 97.16% branch coverage. However, open-source models like DeepSeek-coder-33b are highly competitive, sometimes outperforming commercial counterparts like Gemini-1.0-pro. A key takeaway is the efficacy of prompting: the two-step CoT approach—where the model first identifies logical conditions before generating input—yielded significant gains, such as a +7.99% improvement for Llama 3.1-8b in targeted tasks.

Conclusion and Future Directions

TESTEVAL highlights that while LLMs are proficient at "broad" testing, "deep" logical reasoning for specific execution paths is still a major challenge. Current limitations include a focus on Python and algorithmic problems. Future work should expand to multi-file projects, external dependencies, and "assertion-correct" test generation to better reflect real-world software engineering needs.

Summary updated

BibTeX
@inproceedings{wang2025testeval,
  author = {Wenhan Wang and Chenyuan Yang and Zhijie Wang and Yuheng Huang and Zhaoyang Chu and Da Song and Lingming Zhang and An Ran Chen and Lei Ma},
  title = {{TESTEVAL: Benchmarking Large Language Models for Test Case Generation}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.findings-naacl.197},
}
Figure