Test-Centric Code Generation: Enhancing Test Diversity, Reliability, and Utilization
Chaohang Wen, Zhao Tian, Shiqi Kuang, Chaofan Tao, Shaowei Wang, Xiaohui Li, Haoli Bai, Lifeng Shang, Junjie Chen
Abstract
Large Language Models (LLMs) have made significant progress in code generation, yet the correctness of generated code remains a major challenge, particularly for complex programming tasks. Test-driven code generation offers a promising solution by leveraging automatically generated tests to guide code generation and verification. However, existing approaches often suffer from insufficient test correctness, limited test diversity, and inadequate utilization of test information. To address these limitations, we propose TCG, a test-centric code generation framework comprising three complementary components: Diverse Test Generation, which combines unit tests and property-based tests to improve behavioral coverage; Reliable Test Curation, which employs syntax checking and execution-based cross-validation to identify reliable tests; and Test-Centric Code Generation, which integrates test information into requirement understanding, code verification, and fault repair. We evaluate TCG using three representative LLMs across six function-level and repository-level code generation benchmarks, comparing it with nine representative baselines. Experimental results show that TCG consistently outperforms all applicable baselines across 18 experimental settings, achieving average improvements of 6.63% to 25.59% in Pass@1. These findings demonstrate the effectiveness of leveraging diverse, reliable tests throughout the code generation process.
Create a lesson
Related papers
What Do Code Judges Add Beyond Public Tests and Generator Priors?
Shared title terminologycs.SETaleb Alhajji, Yonghong He
MergeReady-Bench: Evaluating and Improving Coding Agents Beyond Test Passing
Shared title terminologycs.SEPriyatham Kattakinda, Wenxiao Wang, Soheil Feizi
From Suspicious Signals to Crashes: Guiding Bug-Driven GUI Testing via Code-Inspired Tracing
Shared title terminologycs.SEMengzhuo Chen, Zhe Liu, Chunyang Chen et al.
Exploring the Combination of Test Generation and Test Amplification for Regression Testing
Shared title terminologycs.SEDanilo Torquato, Breno Miranda, Antonia Bertolino
Do Vibe-Coded Projects Contain Tests? An Empirical Study
Shared title terminologycs.SEAndre Hora, João Eduardo Montandon, Fabio Petrillo
Who Checks the Model Checkers: Hardened Testing of TLA+ Tools
Shared title terminologycs.SEIgor Konnov