CLOVER: A Test Case Generation Benchmark with Coverage, Long-Context, and Verification

Jiacheng Xu, Bo Pang, Jin Qu, Hiroaki Hayashi, Caiming Xiong, Yingbo Zhou · DOI

Introduction

Automated test generation is a cornerstone of modern software engineering, yet evaluating Large Language Models (LLMs) in this domain remains challenging. Existing benchmarks like HumanEval or MBPP often focus on isolated, short-context algorithmic puzzles that do not reflect the complexity of real-world software repositories. To bridge this gap, we introduce CLOVER, an execution-verified benchmark designed to evaluate LLMs on Python unit test generation across massive context windows (up to 128k tokens). CLOVER mandates strict coverage requirements and multi-file reasoning, revealing significant performance disparities between proprietary and open-source models.

The CLOVER Methodology

The CLOVER benchmark is constructed through an automated pipeline that extracts and verifies test cases from 12 popular, permissive Python repositories, including Flask, Jinja, and Requests. The dataset comprises 845 unique testing problems, which expand to 5,312 evaluation instances when tested across various context lengths.

The CLOVER pipeline for segmenting test files and verifying coverage.

The process involves segmenting existing test files into self-contained cases using Abstract Syntax Tree (AST) parsing. This ensures that each test case retains its necessary setup code while removing unrelated "peer" cases that might clutter the context.

Task Design

CLOVER evaluates models through three escalating tasks:

  1. Task I (Mask Prediction): A cloze-style task requiring the completion of assertion statements within a test.
  2. Task II (Targeted Test Implementation): Open-ended generation of a full test method targeting a specific class or function.
  3. Task III (Coverage-Oriented Test Implementation): The most challenging task, requiring the generation of a test that covers specific code blocks across multiple files (up to 10).

Oracle Retrieval and Verification

To isolate the LLM's reasoning capabilities from the performance of external retrievers, CLOVER employs an "Oracle Retrieval" approach. Using pytest-cov execution data, the benchmark provides the "perfect" context—identifying exactly which source files are exercised by a specific test and prioritizing them based on information gain. Generated tests are then executed in isolated Docker sandboxes to verify syntax, execution, and coverage metrics.

Experimental Results and Insights

The evaluation of various LLMs on CLOVER highlights a stark contrast in how models handle long contexts and complex testing logic.

The Long-Context Performance Gap

A key finding is the "Open-Source Long-Context Collapse." The authors introduce the $\Delta_{max}$ and $\Delta_{min}$ metrics to measure context utilization. Ideally, more relevant context should improve performance ($\Delta_{max} > 0$). While proprietary models like Claude 3.5 Sonnet and GPT-4o effectively utilize longer contexts, many open-source models (e.g., CodeLlama-13B, Mistral-7B, and Qwen 2.5-Coder-14B) suffer sharp performance drops beyond 8k or 16k tokens, often outputting gibberish.

Model performance across varying context lengths, highlighting the long-context collapse in open-source models.

Coverage as the "Final Boss"

Task III proved to be the most difficult for all models. Even with oracle context, the highest success rate was only 32.7% (achieved by GPT-4o at a 64k context). Most open-source models scored below 10%. The authors noted a significant gap between tests that successfully executed and those that actually met the coverage requirements, highlighting the difficulty of precise control flow generation.

Conclusion

CLOVER provides a rigorous framework for evaluating the next generation of coding LLMs. By focusing on execution-verified coverage and long-context reasoning, it exposes the limitations of current models in automating complex regression testing. Future work will involve expanding the benchmark to other languages and exploring agentic, iterative workflows to improve success rates on coverage-driven tasks.

Summary updated

BibTeX
@misc{xu2025clover,
  author = {Jiacheng Xu and Bo Pang and Jin Qu and Hiroaki Hayashi and Caiming Xiong and Yingbo Zhou},
  title = {{CLOVER: A Test Case Generation Benchmark with Coverage, Long-Context, and Verification}},
  year = {2025},
  eprint = {2502.08806},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.08806},
}
Figure