CN-120492333-B - Test case combination generation method, device, system, equipment and medium
Abstract
The embodiment of the application provides a test case combination generation method, a device, a system, equipment and a medium, and relates to the technical field of combined test case generation; each particle represents a test case, similarity among the particles is measured based on a set similarity measurement rule, the particle fitness is dynamically adjusted, iteration is conducted on the fitness according to a set updating rule, when the maximum iteration number or all parameter interaction combinations to be covered are covered, iteration is stopped, a result is output, wherein the output result comprises a global optimal solution or an approximate global optimal solution, the output result is used as a newly generated test case, and efficiency and quality of test case generation are improved.
Inventors
- GUO XU
- JIA YUNTAO
- WEI QIANXIANG
- KANG YUEWEI
- ZHOU JIANTAO
- WU YUEJIA
Assignees
- 内蒙古大学
Dates
- Publication Date
- 20260508
- Application Date
- 20250430
Claims (9)
- 1. The test case combination generation method is characterized by being applied to an automatic test platform and comprising the following steps of: initializing particles and setting a structure among the particles to be a ring topology structure, wherein each particle represents a test case; The method comprises the steps of measuring similarity between particles based on a set similarity measurement rule, and dynamically adjusting the adaptability of the particles, wherein the step of dynamically adjusting the adaptability of the particles comprises the steps of carrying out weighted correction on the adaptability of the particles based on the minimum distance and the coverage radius of the particles from other particles in a population, lifting the adaptability of the particles when the minimum distance of the particles is larger and the coverage radius is smaller, and reducing the adaptability of the particles when the minimum distance is smaller or the coverage radius is larger, wherein the minimum distance is larger and means that the minimum distance of the particles is larger than or equal to a set first distance threshold value, the minimum distance is smaller and means that the minimum distance of the particles is smaller than or equal to a set second distance threshold value, the first distance threshold value is larger than the second distance threshold value, the coverage radius is smaller and means that the coverage radius of the particles is smaller than or equal to a set second radius threshold value, and the first radius threshold value is smaller than the second radius threshold value; iterating the adaptation according to the set updating rule; and when the maximum iteration number or all parameter interaction combinations to be covered are covered, stopping iteration and outputting a result, wherein the output result comprises a global optimal solution or an approximate global optimal solution, and taking the output result as a newly generated test case.
- 2. The test case combination generation method according to claim 1, wherein the initializing particles include: initializing the position and the speed of particles, wherein each particle represents a test case, and the position of each particle corresponds to a parameter value combination of the test case; initializing a historical optimal solution of each particle to be an initial position of the particle, and initializing optimal solutions in all particles to be global optimal solutions; sorting all particles according to fitness, and selecting a current optimal individual as a first leading particle; selecting a plurality of particles within a preset radius based on cosine distance by taking the leading particles as the center, and forming a niche with the leading particles; Removing all particles within the niche from the main population; Repeating the operation, and continuing to select new leading particles from the residual particles and divide the niches until all the particles are distributed; And setting the particles with optimal fitness in each niche as corresponding local optimal solutions.
- 3. The test case combination generation method according to claim 1, wherein the measuring the similarity between particles based on the set similarity measurement rule includes: The difference degree between any two test cases in the coverage array is measured by the distance, wherein the larger the minimum distance is, the more obvious the difference between the test cases is; the calculation formula of the minimum distance is as follows: ; Wherein, C is a coverage array and comprises test case sets, x and y are any two test cases in the coverage array; Representing a distance measure between the two; the coverage capability of the coverage group in the whole test space is measured through the coverage radius, wherein the larger the coverage radius is, the more test cases can be covered by the coverage group; The coverage radius is calculated as follows: ; where g is an ideal point in the test space, and x is any test case in the coverage array.
- 4. The test case combination generation method of claim 1, wherein the dynamically adjusting the fitness of the particles comprises: adjusting the fitness of the particle calculation according to the minimum distance and the coverage radius: ; Wherein, the For the degree of the original fit, At the level of the minimum distance to be reached, To cover the radius; And To set a constant.
- 5. The test case combination generation method according to claim 1, wherein the iterating the fitness according to the set update rule includes: If the current fitness of the particles is better than the fitness of the historical optimal solution, updating the historical optimal solution to be the current position of the particles; If the calculated fitness of the particles in the niche is better than the local optimal solution in the current niche, updating the local optimal solution in the current niche into the position of the particles in the calculated niche; If the current fitness of the particles is better than the fitness of the global optimal solution, updating the global optimal solution to the current position of the particles; Update the speed of the particles: ; Wherein, the Representing the individual historical optimal position of the ith particle; Representing the historical best location of the ith particle within the belonging niche; updating the position of the particles: ; Wherein, the As a vector of the position of the object, ; Wherein, the As a velocity vector of the velocity vector, ; Wherein, the And The position and velocity of the particles at time t are indicated respectively, And Updated position and velocity, respectively; Is an inertial weight factor; And An acceleration factor greater than zero; ; when updating the position of the particle, a boundary check is performed so that the particle position is within the scope of the definition field.
- 6. The utility model provides a test case combination generating device which is characterized in that, integrate in automatic test platform, include: the particle initialization module is used for initializing particles and setting a structure among the particles to be a ring topology structure, wherein each particle represents a test case; The particle measurement module is used for measuring the similarity between particles based on a set similarity measurement rule and dynamically adjusting the fitness of the particles, wherein the dynamic adjustment of the fitness of the particles comprises the steps of carrying out weighted correction on the fitness of the particles based on the minimum distance and the coverage radius of the particles and other particles in a population, improving the fitness of the particles when the minimum distance and the coverage radius of the particles are larger, and reducing the fitness of the particles when the minimum distance or the coverage radius is larger, wherein the minimum distance is larger and means that the minimum distance of the particles is larger than or equal to a set first distance threshold value, the minimum distance is smaller and is equal to a set second distance threshold value, the first distance threshold value is larger and is equal to a set first radius threshold value, and the coverage radius is larger and is equal to a set second radius threshold value, and the first radius threshold value is smaller and is equal to a set second radius threshold value; The iteration processing module is used for iterating the adaptability according to the set updating rule; And the use case output module is used for stopping iteration and outputting a result when the maximum iteration number or all parameter interaction combinations to be covered are covered, wherein the output result comprises a global optimal solution or an approximate global optimal solution, and the output result is used as a newly generated test use case.
- 7. A test case combination generating system is characterized in that the test case combination generating system comprises an automatic test platform, wherein the automatic test platform comprises a test case combination generating module, a case operation module, a visualization module and the test case combination generating device as set forth in claim 6, wherein the test case combination generating device is connected with the test case combination generating module; The test case combination generating module is used for parameter input and algorithm selection, the case operation module is used for parameter modification and parameter deletion, and the visualization module is used for displaying test results and chart analysis.
- 8. An electronic device, comprising: The test case combination generation method according to any one of claims 1-5, wherein the processor is connected with the memory through the bus, and the memory stores computer readable instructions, when the computer readable instructions are executed by the processor.
- 9. A computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and when executed by a server, the computer program implements the test case combination generation method according to any one of claims 1 to 5.
Description
Test case combination generation method, device, system, equipment and medium Technical Field The application relates to the technical field of combined test case generation, in particular to a method, a device, a system, equipment and a medium for generating a test case combination. Background The existing combined test case generation method, such as Particle Swarm Optimization (PSO) algorithm and Genetic Algorithm (GA), relies on heuristic optimization method, has strong global searching capability, and can find out the test case set with high coverage rate in a large input space. However, the optimization objective of these algorithms is usually focused on improving coverage, failing to effectively control the scale of the test case set. Because of the lack of scale control, test case sets often contain redundant test cases, resulting in test set scales that exceed practical requirements. The method not only increases the computing resource, the storage space and the execution time, but also increases the test cost and affects the test efficiency, so that all cases cannot be fully executed in a limited test period, and further the test quality is affected. Disclosure of Invention The embodiment of the application aims to provide a test case combination generation method, a device, a system, equipment and a medium, which are used for solving the problems of low test efficiency and poor test quality of the existing combination test case generation method. In a first aspect, an embodiment of the present application provides a test case combination generating method, which is applied to an automated test platform, and includes: initializing particles and setting a structure among the particles to be a ring topology structure, wherein each particle represents a test case; based on a set similarity measurement rule, measuring the similarity between particles, and dynamically adjusting the adaptability of the particles; iterating the adaptation according to the set updating rule; and when the maximum iteration number or all parameter interaction combinations to be covered are covered, stopping iteration and outputting a result, wherein the output result comprises a global optimal solution or an approximate global optimal solution, and taking the output result as a newly generated test case. In the implementation process, the method comprises the steps of initializing particles, setting a structure among the particles to be a ring topology structure, wherein each particle represents a test case, measuring the similarity among the particles based on a set similarity measurement rule, dynamically adjusting the adaptability of the particles, iterating the adaptability according to a set updating rule, stopping iteration when the maximum iteration number or all parameter interaction combinations to be covered are covered, outputting a result, wherein the output result comprises a global optimal solution or an approximate global optimal solution, the output result is used as a newly generated test case, dynamically adjusting the adaptability of the particles based on the ring topology structure and the similarity measurement rule through an operation automation test platform, generating a test case combination, and improving the efficiency and quality of test case generation. Further, the dynamically adjusting the fitness of the particles includes: The adaptability of the particles is subjected to weighted correction based on the minimum distance and the coverage radius between the particles and other particles in the population; when the minimum distance of the particles is larger and the coverage radius is smaller, the fitness of the particles is improved; when the minimum distance is smaller or the coverage radius is larger, the fitness of the particle is reduced. In the implementation process, the fitness of the particles is dynamically adjusted so as to generate test case combinations by adjusting the fitness later. Further, the initializing particle includes: initializing the position and the speed of particles, wherein each particle represents a test case, and the position of each particle corresponds to a parameter value combination of the test case; initializing a historical optimal solution of each particle to be an initial position of the particle, and initializing optimal solutions in all particles to be global optimal solutions; sorting all particles according to fitness, and selecting a current optimal individual as a first leading particle; selecting a plurality of particles within a preset radius based on cosine distance by taking the leading particles as the center, and forming a niche with the leading particles; Removing all particles within the niche from the main population; Repeating the operation, and continuing to select new leading particles from the residual particles and divide the niches until all the particles are distributed; And setting the particles with optimal fitness in each niche a