CoCoEvo: Co-Evolution of Programs and Test Cases to Enhance Code Generation
- 28 July 2025
- journal article
- Published by Institute of Electrical and Electronics Engineers (IEEE) in IEEE Transactions on Evolutionary Computation
- Vol. PP (1089778X) , 1
Abstract
Large Language Models (LLMs) have shown remarkable performance in automated code generation. However, existing approaches often rely heavily on pre-defined test cases, which become impractical in scenarios where such cases are unavailable. While prior works explore filtering techniques between programs and test cases, they overlook the refinement of test cases. To address this limitation, we introduce CoCoEvo, a novel LLM-based co-evolution framework that simultaneously evolves programs and test cases. CoCoEvo eliminates the dependency on pre-defined test cases by generating both programs and test cases directly from natural language problem descriptions and function headers. The framework employs specialized evolutionary operators, including LLM-based crossover and mutation operators for program evolution, along with an additional test case generation operator for test case evolution. Additionally, we propose optimization strategies such as a crossover rate scheduler to balance exploration and convergence, and a multi-objective optimization method for test case selection. Experimental results on multiple state-of-the-art LLMs demonstrate that CoCoEvo surpasses existing methods, achieving state-of-the-art performance in automated code generation and testing. These results underscore the potential of co-evolutionary techniques in advancing the field of automated programming.Keywords
All Related Versions
Funding Information
- National Natural Science Foundation of China (62202023)
This publication has 25 references indexed in Scilit:
- AutoTest: Evolutionary Code Solution Selection with Test Cases2024
- Evolutionary Testing for Program Repair2024
- The OpenELM Library: Leveraging Progress in Language Models for Novel Evolutionary Algorithms2024
- Mathematical discoveries from program search with large language modelsNature, 2023
- An Empirical Evaluation of Using Large Language Models for Automated Unit Test GenerationIEEE Transactions on Software Engineering, 2023
- Large Language Models are Few-shot Testers: Exploring LLM-based General Bug Reproduction2023
- Competition-level code generation with AlphaCodeScience, 2022
- EvoSuite2011
- Coevolving programs and unit tests from their specification2007
- A Fast Elitist Non-dominated Sorting Genetic Algorithm for Multi-objective Optimization: NSGA-II2000