With the rapid development of computer networks,various types of software are playing an increasingly important role in people’s lives,and the scale of software has become increasingly large and complex due to the increase in demand.How to ensure and improve the quality of software production is a key issue at present.Software testing,as the main means to ensure software quality,runs through the entire software development process.However,manually designing test cases is a time-consuming and labor-intensive process.In order to improve the efficiency of testing work,automatic generation of test cases has become a hot research topic in the field of software testing.Genetic algorithms are widely used in automatic search and generation of test cases due to their high robustness and strong global search ability.In genetic algorithms,the design of fitness functions has a significant impact on the efficiency of the algorithm.Many studies have focused on optimizing fitness functions;In addition,genetic algorithm itself has the defect of poor local search ability,resulting in low coverage and slow convergence of genetic algorithm in generating test cases.In this thesis,the following studies have been conducted on two types of problems in automatic generation of test cases using genetic algorithms:(1)A design idea of dynamic fitness function is proposed.In the process of population evolution,the fitness function also evolves synchronously,which is different from evaluating the adaptability of a single test case to the target path in isolation in the past.This thesis considers the impact of the evolution process on the fitness evaluation ability.The experimental results show that the proposed method in this thesis improves the target path coverage and reduces the average number of iterations compared to other algorithms.(2)Aiming at the problem of poor local search ability of genetic algorithms,an improved Bayesian optimization genetic algorithm is proposed.When the genetic algorithm converges to a certain degree,a Tree-structured Parzen Estimator is used as a probabilistic proxy model to model the fitness function and complete local detail search.The experimental results show that the proposed method has advantages in convergence speed and target path coverage.(3)Based on the proposed improved algorithm,an automatic test case generation system is designed and implemented.The system can perform static analysis of the program under test,generate a control flow graph,and provide all paths of the program.The tester can select the target path,and then the system can use the proposed improved algorithm to automatically generate test cases for the target path and generate test reports.In addition,the system also has functions such as login registration,test case management,and tester management. |