首页 | 本学科首页   官方微博 | 高级检索  
     检索      

基于损失函数的单元测试用例自动化生成算法研究与实现
引用本文:傅瑞华,李凡,王俊峰.基于损失函数的单元测试用例自动化生成算法研究与实现[J].四川大学学报(自然科学版),2022,59(3):032002-58.
作者姓名:傅瑞华  李凡  王俊峰
作者单位:四川大学计算机学院,四川大学计算机学院,四川大学计算机学院
基金项目:国家重点研发计划项目(2018YFB0804503, 2019QY1400);国家自然科学基金项目(U20A20161, U1836103);基础加强计划项目(2019-JCJQ-ZD-113)
摘    要:软件测试是软件开发过程中最为耗时的阶段之一.通过自动执行大量的测试用例,可以高效、及时地发现软件程序中潜在的错误,这是提高大中型软件开发质量的重要技术发展趋势.目前较多的元启发式优化算法已经能够实现测试用例的自动生成,但测试效率较低且开销较大,所以如何使得生成的测试用例在数量较少的情况下覆盖尽可能多的目标,就成为自动化测试用例生成中的核心技术问题.本文提出一种基于损失函数的单元测试用例自动化生成算法(LFGA),在遗传算法的执行过程中,根据测试用例种群的路径覆盖情况,动态改变后续种群的分布,保证整体数据分布的平衡性.并利用分支信息优化自适应交叉变异算子,自动生成规模尽可能小且高覆盖的有效测试用例集.实验结果表明,相比于已有的自动生成测试用例方法,较好地解决了传统模型中初值依赖、收敛早熟、局部寻优能力滞后等缺陷,保证了生成的测试用例平均覆盖率达到95%,提升了搜索效率及数据使用效率.

关 键 词:软件测试  自动生成  损失函数  自适应  改进遗传算法
收稿时间:2021/10/3 0:00:00
修稿时间:2021/12/17 0:00:00

Research and implementation of an algorithm for automatic generation of unit test cases based on loss function
FU Rui-Hu,LI Fan and WANG Jun-Feng.Research and implementation of an algorithm for automatic generation of unit test cases based on loss function[J].Journal of Sichuan University (Natural Science Edition),2022,59(3):032002-58.
Authors:FU Rui-Hu  LI Fan and WANG Jun-Feng
Institution:College of Computer Science, Sichuan University,College of Computer Science, Sichuan University,College of Computer Science, Sichuan University
Abstract:Software testing is one of the most time-consuming stages in the software development process. Potential errors in software can be found efficiently and in a timely manner by automatically executing a large number of test cases, which is an important technology development trend to improve the quality of large and medium-sized software development. Currently more meta-heuristic optimization algorithms have been able to automatically generate test cases, but the test efficiency is low and the overhead is large, so how to make the generated test cases cover as many goals as possible with a small number of test cases is the core technical issues in the generation of automated test cases. This paper proposes a loss function-based automatic generation algorithm for unit test cases (LFGA). During the execution of the genetic algorithm, the subsequent population distribution is changed dynamically to ensure the balance of the overall data distribution according to the path coverage of the test case population. The branch information is introduced to optimize the adaptive cross-mutation operator to automatically generate an effective test case set with as small scale and high coverage as possible. The experimental results show that, compared with the existing automatic test case generation method, the method proposed in this paper can better solve the defects of the traditional model such as initial value dependence, premature convergence, and lagging local optimization ability, and the average coverage rate of generated test cases reaches 95%, which improves search efficiency and data utilization efficiency.
Keywords:Software testing  Automatic generation  Loss function  Adaptive  Improved genetic algorithm
点击此处可从《四川大学学报(自然科学版)》浏览原始摘要信息
点击此处可从《四川大学学报(自然科学版)》下载免费的PDF全文
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号