| As an indispensable part in the software life cycle,the software testing is extremely important for ensuring the software quality.With the continuous increase of software scale,the workload of software testing increases dramatically.In order to improve testing efficiency,automated testing has been developed rapidly.However,most of the existing automated unit testing tools only provide the execution drive of use cases,and the test data required by test cases still need to be designed manually,while for programs with complex structures,it is difficult to design data that meet the coverage criteria in a short time.Therefore,the automatic generation of test data is very necessary for improving the efficiency of unit testing.In this paper,the goal is to automatically generate test data that meets the path coverage criteria,and research the single path oriented and multipath oriented test data generation methods based on intelligent optimization algorithms.The main work is as follows:(1)In view of the shortcomings of the existing automatic instrumentation technology,this paper proposes an automatic instrumentation method based on lexical grammar analysis at the source code level.By improving the determination method of the instrumentation position and the storage method of the "probe",we can speed up the pile insertion,reduce the code expansion rate,and lay a foundation for the subsequent calculation of the similarity between the target path and the actual path.(2)The method of fitness function construction and automatic test data generation for single path.First,for the construction of single path fitness function,this paper proposes a method based on layer proximity method,which uses the construction method of fitness function based on overlapping paths to realize the construction of single path fitness function.Aiming at the automatic test data generation algorithm for path coverage,this paper proposes an automatic test data generation method based on shuffled frog leaping algorithm,and improves the shortcomings of the algorithm.The dynamic threshold is introduced to control the moving step size of the frog,balancing the global development and local search capabilities of the algorithm;Change the random jumping strategy of the worst frog individual to learn from the random individuals in the population,which enhances the information exchange between individuals and improves the global search ability of the algorithm.(3)Multipath oriented test data generation algorithm.For the construction of multi-path fitness function,analyze the factors that affect the similarity between paths.Through the introduction of Monte Carlo algorithm,the quantitative analysis of the influencing factors is realized,so that the fitness value obtained can play a positive role in guiding the algorithm and improving the efficiency of test data generation.Finally,the proposed automatic instrumentation method is organically combined with automatic test data generation for single path and multi-path.The experiment shows that the test data generation method based on the improved shuffled frog leaping algorithm can efficiently generate test data for path coverage and improve the efficiency of unit testing. |