Search-Based Software Testing (SBST) is a well-established approach for automated unit test generation, yet it often suffers from premature convergence and limited diversity in the generated test suites. Recently, Large Language Models (LLMs) have emerged as an alternative technique for unit test generation. We present EvoGPT, a hybrid test generation system that integrates LLM-based test generation with SBST-based test suite optimization. EvoGPT uses LLMs to generate an initial population of test suites, and uses an Evolutionary Algorithm (EA) to further optimize this test suite population. A distinguishing feature of EvoGPT is its explicit enforcement of diversity, achieved through the use of multiple temperatures and prompt instructions during test generation. In addition, each LLM-generated test is refined using a generation-repair loop and coverage-guided assertion generation. To address evolutionary plateaus, EvoGPT also detects stagnation during search and injects additional LLM-generated tests aimed at previously uncovered branches. Here too diversity is enforced using multiple temperatures and prompt instructions. We evaluate EvoGPT on Defects4J, a standard benchmark for test generation. The results show that EvoGPT achieves, on average, a 10% improvement in both code coverage and mutation score metrics compared to TestART, an LLM-only baseline; and EvoSuite, a standard SBST baseline. An ablation study indicates that explicitly enforcing diversity both at initialization and during the search is key to effectively leveraging LLMs for automated unit test generation.


翻译:基于搜索的软件测试(SBST)是一种成熟的自动化单元测试生成方法,但其生成的测试套件常面临早熟收敛和多样性不足的问题。近期,大型语言模型(LLMs)已成为单元测试生成的替代技术。本文提出EvoGPT,一种融合LLM测试生成与SBST测试套件优化的混合测试生成系统。EvoGPT使用LLMs生成初始测试套件种群,并采用进化算法(EA)对该种群进行优化。EvoGPT的显著特征是通过在测试生成阶段采用多温度参数和多样化提示指令,显式增强多样性。此外,每个LLM生成的测试均通过生成-修复循环和覆盖率引导的断言生成进行精炼。针对进化停滞问题,EvoGPT在搜索过程中检测平台期,并注入针对未覆盖分支的LLM生成测试,此过程同样通过多温度参数和提示指令保持多样性。我们在Defects4J标准测试生成基准上评估EvoGPT,结果表明:相较于纯LLM基线TestART和标准SBST基线EvoSuite,EvoGPT在代码覆盖率和变异分数指标上平均提升10%。消融实验证实,在初始化和搜索阶段显式增强多样性是有效利用LLMs进行自动化单元测试生成的关键。

0
下载
关闭预览

相关内容

LLMs与生成式智能体模拟:复杂系统研究的新范式
专知会员服务
27+阅读 · 2025年6月15日
利用多个大型语言模型:关于LLM集成的调研
专知会员服务
35+阅读 · 2025年2月27日
揭示生成式人工智能 / 大型语言模型(LLMs)的军事潜力
专知会员服务
31+阅读 · 2024年9月26日
如何检测LLM内容?UCSB等最新首篇《LLM生成内容检测》综述
一文读懂目标检测:R-CNN、Fast R-CNN、Faster R-CNN、YOLO、SSD
七月在线实验室
11+阅读 · 2018年7月18日
YOLO V3 检测框架以及它的前世今生 | Paper Reading
MomentaAI
12+阅读 · 2018年5月15日
【下载】PyTorch 实现的YOLO v2目标检测算法
专知
15+阅读 · 2017年12月27日
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员