Planning to Explore: Curiosity-Driven Planning for LLM Test Generation
Summary: arXiv:2604.05159v1 Announce Type: cross
Abstract
The use of Large Language Models (LLMs) for code generation has naturally extended to code testing and evaluation. As codebases grow in size and complexity, so does the need for automated test generation. Current approaches for LLM-based test generation rely on strategies that maximize immediate coverage gain, a greedy approach that plateaus on code where reaching deep branches requires setup steps that individually yield zero new coverage.
Drawing on principles of Bayesian exploration, we treat the program’s branch structure as an unknown environment, with an evolving coverage map serving as a proxy probabilistic posterior representing what the LLM has discovered so far. Our method, CovQValue, feeds the coverage map back to the LLM, generates diverse candidate plans in parallel, and selects the most informative plan by LLM-estimated Q-values. This method seeks actions that balance immediate branch discovery with future reachability.
Key Findings
- Improved Performance: Our method outperforms greedy selection on TestGenEval Lite, achieving 51-77% higher branch coverage across three popular LLMs.
- Target Success: CovQValue wins on 77-84% of targets, demonstrating its efficacy in test generation.
- New Benchmark: We build a benchmark for iterative test generation, RepoExploreBench, where we achieve 40-74% branch coverage improvements.
Methodology
CovQValue utilizes a unique approach to test generation that emphasizes curiosity-driven exploration. By leveraging the information from the coverage map, the model generates multiple candidate plans. This parallel generation allows the LLM to evaluate potential actions based on their estimated future impact, rather than merely optimizing for immediate gains.
The core idea is to treat the branch structure of a program as a dynamic environment, where the LLM’s exploration can lead to a better understanding of the code’s behavior over time. The use of Q-values allows for a more informed selection process, guiding the LLM towards actions that promise long-term benefits.
Implications for Future Research
The findings from this research highlight the potential of integrating curiosity-driven planning methods into LLM-based exploration for automated test generation. As software complexity continues to escalate, the need for more efficient and effective testing solutions becomes increasingly critical.
This study opens up several avenues for future research, including:
- Exploring additional strategies for enhancing the coverage map’s accuracy.
- Investigating the application of CovQValue in different programming languages and environments.
- Developing further benchmarks for evaluating LLM performance in automated testing.
Conclusion
In conclusion, the application of curiosity-driven planning for LLM test generation represents a significant advancement in the field of automated software testing. By focusing on long-term exploration and discovery, CovQValue offers a promising alternative to traditional greedy approaches, paving the way for more robust testing methodologies in an increasingly complex coding landscape.
