Benchmarking LLMs for Unit Test Generation from Real-World Functions
UnLeakedTestBench is a rigorous benchmark for evaluating Large Language Models (LLMs) on function-level unit test generation. It addresses critical limitations in existing benchmarks by providing:
Our evaluation of 12 state-of-the-art LLMs reveals that UnLeakedTestBench presents significantly greater challenges than existing benchmarks, with models achieving only:
| Benchmark | # Functions | Avg. Cyclomatic Complexity | Data Status |
|---|---|---|---|
| UnLeakedTestBench | 3,909 | 14.87 | Decontaminated |
| PreLeakedTestBench | 18,169 | 14.52 | Mixed (includes leaked) |
| TestEval | 210 | - | Not decontaminated |
# Create conda environment
conda create -n unleaked python=3.12
conda activate unleaked
# Install required packages
pip install cosmic-ray pytest pytest-cov
For running the full evaluation pipeline, you may need:
pip install openai anthropic transformers torch
UnLeakedTestBench uses a K-query iterative test generation task:
This iterative process encourages test diversity and comprehensive coverage.
Proportion of correct, executable test cases:
Pass@k = (Σ Correct_Tests_i) / (N × K)
where N is the number of functions and K is the number of queries.
Fault detection capability using Cosmic-Ray mutation testing:
Mut@k = (Σ Killed_Mutants_i) / N
Higher mutation scores indicate better bug-finding ability.
| Metric | UnLeakedTestBench | PreLeakedTestBench | TestEval |
|---|---|---|---|
| Pass@1 | 41.32% | 47.07% | 91.79% |
| LCov@k | 45.10% | 55.13% | 92.18% |
| BCov@k | 30.22% | 40.07% | 82.04% |
| Mut@k | 40.21% | 50.80% | 49.69% |
We evaluated 12 state-of-the-art LLMs:
| Family | Models |
|---|---|
| CodeLlama | CodeLlama-7b-Instruct-hf |
| Seed-Coder | Seed-Coder-8B-Instruct |
| DeepSeekCoder | deepseek-coder-{1.3b, 6.7b, 33b}-instruct |
| Gemma-3 | gemma-3-{4b, 12b, 27b}-it |
| Qwen2.5-Coder | Qwen2.5-Coder-{7B, 14B, 32B}-Instruct |
| Microsoft Phi-4 | Phi-4-mini-instruct |
Important: To preserve benchmark integrity and prevent test case leakage into future LLM training sets, we do not release the ground-truth tests. Instead, we provide:
This approach allows researchers to evaluate new models while maintaining the benchmark's scientific validity.
We welcome contributions to improve UnLeakedTestBench! Areas of interest:
Please open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
For questions, issues, or collaborations:
UnLeakedTestBench - Setting a higher bar for LLM test generation evaluation
6 commits
Python
100.0%
Benchmarking LLMs for Unit Test Generation from Real-World Functions
UnLeakedTestBench is a rigorous benchmark for evaluating Large Language Models (LLMs) on function-level unit test generation. It addresses critical limitations in existing benchmarks by providing:
Our evaluation of 12 state-of-the-art LLMs reveals that UnLeakedTestBench presents significantly greater challenges than existing benchmarks, with models achieving only:
| Benchmark | # Functions | Avg. Cyclomatic Complexity | Data Status |
|---|---|---|---|
| UnLeakedTestBench | 3,909 | 14.87 | Decontaminated |
| PreLeakedTestBench | 18,169 | 14.52 | Mixed (includes leaked) |
| TestEval | 210 | - | Not decontaminated |
# Create conda environment
conda create -n unleaked python=3.12
conda activate unleaked
# Install required packages
pip install cosmic-ray pytest pytest-cov
For running the full evaluation pipeline, you may need:
pip install openai anthropic transformers torch
UnLeakedTestBench uses a K-query iterative test generation task:
This iterative process encourages test diversity and comprehensive coverage.
Proportion of correct, executable test cases:
Pass@k = (Σ Correct_Tests_i) / (N × K)
where N is the number of functions and K is the number of queries.
Fault detection capability using Cosmic-Ray mutation testing:
Mut@k = (Σ Killed_Mutants_i) / N
Higher mutation scores indicate better bug-finding ability.
| Metric | UnLeakedTestBench | PreLeakedTestBench | TestEval |
|---|---|---|---|
| Pass@1 | 41.32% | 47.07% | 91.79% |
| LCov@k | 45.10% | 55.13% | 92.18% |
| BCov@k | 30.22% | 40.07% | 82.04% |
| Mut@k | 40.21% | 50.80% | 49.69% |
We evaluated 12 state-of-the-art LLMs:
| Family | Models |
|---|---|
| CodeLlama | CodeLlama-7b-Instruct-hf |
| Seed-Coder | Seed-Coder-8B-Instruct |
| DeepSeekCoder | deepseek-coder-{1.3b, 6.7b, 33b}-instruct |
| Gemma-3 | gemma-3-{4b, 12b, 27b}-it |
| Qwen2.5-Coder | Qwen2.5-Coder-{7B, 14B, 32B}-Instruct |
| Microsoft Phi-4 | Phi-4-mini-instruct |
Important: To preserve benchmark integrity and prevent test case leakage into future LLM training sets, we do not release the ground-truth tests. Instead, we provide:
This approach allows researchers to evaluate new models while maintaining the benchmark's scientific validity.
We welcome contributions to improve UnLeakedTestBench! Areas of interest:
Please open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
For questions, issues, or collaborations:
UnLeakedTestBench - Setting a higher bar for LLM test generation evaluation
6 commits
Python
100.0%