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

Clc Number:

TP311.1

Fund Project:

  • Article
  • |
  • Figures
  • |
  • Metrics
  • |
  • Reference
  • |
  • Related
  • |
  • Cited by
    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.

    Reference
    Related
    Cited by
Get Citation

Cite this article as: FU Rui-Hua, LI Fan, WANG Jun-Feng. Research and implementation of an algorithm for automatic generation of unit test cases based on loss function [J]. J Sichuan Univ: Nat Sci Ed, 2022, 59: 032002.

Copy
Share
Article Metrics
  • Abstract:
  • PDF:
  • HTML:
  • Cited by:
History
  • Received:October 03,2021
  • Revised:December 17,2021
  • Adopted:January 04,2022
  • Online: May 30,2022
  • Published: