基于损失函数的单元测试用例自动化生成算法研究与实现
作者:
作者单位:

四川大学计算机学院

作者简介:

通讯作者:

中图分类号:

TP311.1

基金项目:

国家重点研发计划项目(2018YFB0804503, 2019QY1400);国家自然科学基金项目(U20A20161, U1836103);基础加强计划项目(2019-JCJQ-ZD-113)


Research and implementation of an algorithm for automatic generation of unit test cases based on loss function
Author:
Affiliation:

1.College of Computer Science, Sichuan University, Chengdu 610065, China;2.College of Computer Science, Sichuan University, Chengdu 610065, Chinaity

Fund Project:

  • 摘要
  • |
  • 图/表
  • |
  • 访问统计
  • |
  • 参考文献
  • |
  • 相似文献
  • |
  • 引证文献
  • |
  • 资源附件
  • |
  • 文章评论
    摘要:

    软件测试是软件开发过程中最为耗时的阶段之一.通过自动执行大量的测试用例,可以高效、及时地发现软件程序中潜在的错误,这是提高大中型软件开发质量的重要技术发展趋势.目前较多的元启发式优化算法已经能够实现测试用例的自动生成,但测试效率较低且开销较大,所以如何使得生成的测试用例在数量较少的情况下覆盖尽可能多的目标,就成为自动化测试用例生成中的核心技术问题.本文提出一种基于损失函数的单元测试用例自动化生成算法(LFGA),在遗传算法的执行过程中,根据测试用例种群的路径覆盖情况,动态改变后续种群的分布,保证整体数据分布的平衡性.并利用分支信息优化自适应交叉变异算子,自动生成规模尽可能小且高覆盖的有效测试用例集.实验结果表明,相比于已有的自动生成测试用例方法,较好地解决了传统模型中初值依赖、收敛早熟、局部寻优能力滞后等缺陷,保证了生成的测试用例平均覆盖率达到95%,提升了搜索效率及数据使用效率.

    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.

    参考文献
    相似文献
    引证文献
引用本文

引用本文格式: 傅瑞华,李凡,王俊峰. 基于损失函数的单元测试用例自动化生成算法研究与实现[J]. 四川大学学报: 自然科学版, 2022, 59: 032002.

复制
分享
文章指标
  • 点击次数:
  • 下载次数:
  • HTML阅读次数:
  • 引用次数:
历史
  • 收稿日期:2021-10-03
  • 最后修改日期:2021-12-17
  • 录用日期:2022-01-04
  • 在线发布日期: 2022-05-30
  • 出版日期: