[Paper Review] TESTEVAL: Benchmarking Large Language Models for Test Case Generation
This paper introduces TestEval, a benchmark for evaluating large language models (LLMs) in test case generation for Python programs. It evaluates 16 LLMs across three tasks—overall, targeted line/branch, and targeted path coverage—revealing that current LLMs struggle with program logic comprehension, especially in targeted coverage despite strong performance in general test case diversity.
Testing plays a crucial role in the software development cycle, enabling the detection of bugs, vulnerabilities, and other undesirable behaviors. To perform software testing, testers need to write code snippets that execute the program under test. Recently, researchers have recognized the potential of large language models (LLMs) in software testing. However, there remains a lack of fair comparisons between different LLMs in terms of test case generation capabilities. In this paper, we propose TESTEVAL, a novel benchmark for test case generation with LLMs. We collect 210 Python programs from an online programming platform, LeetCode, and design three different tasks: overall coverage, targeted line/branch coverage, and targeted path coverage. We further evaluate sixteen popular LLMs, including both commercial and open-source ones, on TESTEVAL. We find that generating test cases to cover specific program lines/branches/paths is still challenging for current LLMs, indicating a lack of ability to comprehend program logic and execution paths. We have open-sourced our dataset and benchmark pipelines at https://github.com/LLM4SoftwareTesting/TestEval.
Motivation & Objective
- Address the lack of standardized benchmarks for evaluating LLMs in automated test case generation.
- Investigate whether LLMs can generate test cases to achieve high overall coverage, target specific lines/branches, or follow specific execution paths.
- Provide a public, reproducible benchmark to accelerate research in LLM-based software testing.
- Compare both commercial and open-source LLMs on their ability to generate semantically correct and coverage-guided test cases.
- Identify limitations in LLM reasoning for program logic understanding during test generation.
Proposed method
- Collected 210 Python programs from LeetCode as the benchmark dataset.
- Designed three distinct test case generation tasks: overall coverage, targeted line/branch coverage, and targeted path coverage.
- Constructed standardized prompt templates for each task to ensure consistent LLM input across models.
- Implemented a two-stage correctness check: syntactic validation and execution testing via program execution.
- Used coverage metrics (statement, branch, path) to evaluate test case effectiveness.
- Evaluated 16 LLMs, including commercial (e.g., GPT-4) and open-source (e.g., Llama, DeepSeek, Qwen) models, under identical conditions.

Experimental results
Research questions
- RQ1Can LLMs generate diverse and executable test cases that achieve high overall code coverage?
- RQ2To what extent can LLMs generate test cases targeting specific program lines or branches based on natural language instructions?
- RQ3Can LLMs generate test cases that follow a specific execution path as intended by the tester?
- RQ4How do commercial and open-source LLMs compare in their ability to generate coverage-guided test cases?
- RQ5What are the key limitations in LLM reasoning for understanding program logic during test case generation?
Key findings
- Commercial LLMs like GPT-4 outperform open-source models in both overall and targeted coverage tasks.
- In targeted line coverage, 12 out of 16 LLMs showed improvements ≤5% even when given target line information, indicating poor comprehension of program logic.
- For targeted path coverage, performance gains were minimal (e.g., 2.73% improvement for DeepSeek-33B), suggesting difficulty in path-aware test generation.
- Despite high syntactic correctness (e.g., 99.77% for CodeQwen-7B), many models failed to generate functionally correct test cases for complex logic.
- Models like Mistral-0.3 and smaller open-source LLMs performed poorly, with path coverage below 33% and line coverage under 23%.
- The benchmark reveals a consistent gap in LLMs’ ability to reason about control flow and execution paths, even when prompted with detailed descriptions.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.