Automatic test data generation technology is a key technology to improve the efficiency of software testing, and to raise software's reliability. The technology can reduce the high cost of manual testing, improve the trustworthiness of the testing process and change the status which testers have to design test data all by their experience. People use all kinds of heuristic search algorithms, especially artificial intelligence search algorithms as the core method to realize automatic test data generation and make some achievements.Researches on GA-based automatic test data generation take up the majority. But the genetic algorithm involves comparatively more parameters, makes a lot of CPU time encoding and decoding, and the efficiency of GA is relatively low. The Particle Swarm Optimization (PSO) which has relatively simple model, less parameters to set provides a new way of thinking to solve the problem of automatic test data generation. Researchers have proved the high efficiency when using PSO to generate test data and point out that PSO has good prospects in this field.This paper proposes a method of automatic test data generation based on Simple Particle Swarm Optimization (sPSO) to improve the availability and efficiency when using search algorithms to generate test data. sPSO has particle velocity items removed compared with the basic PSO and it realizes the process of evolution only by updating its particle position.The major work of this paper includes:(1) Study the commonly used test data generation methods, analyze and compare the characteristics of genetic algorithms, simulated annealing, particle swarm optimization which is generally used in automatic test data generation field, and make preparations for the following research.;(2) Based on the characteristics of sPSO, make preliminary study on the inertia weight (w) parameter. Propose that a small value of w can greatly improve the efficiency of test data generation in some special procedures;(3) Setting random w for every particle to solve the problem that traditional setting mode for w often causes uneven traverse of particles in sPSO; (4) Propose the method of test data normalization to solve the problem that the particles move out of the search domain frequently when using sPSO to generate test data. (4) For the purpose of jumping out of local optimal value and accelerating the convergence rate, this paper adds a new disturbed strategy to sPSO. The specific method is:Take the generations of global extreme's evolutionary stagnation as a trigger. Use the deviation of mean elite method to determine whether premature convergence occurred. In case of premature, re-initialize the population, otherwise, use simulated annealing algorithm to optimize the global extreme; (5) Apply the improved sPSO to generate path test data. Prove the practicability and efficiency of the method by experiments. |