Test case combination generation method, device, system, apparatus and medium

By using an improved niche particle swarm optimization algorithm, initializing particles into a circular topology and dynamically adjusting particle fitness, the problem of insufficient scale control in the generation of combined test cases is solved, thereby improving the efficiency and quality of test case generation.

CN120492333BActive Publication Date: 2026-05-08INNER MONGOLIA UNIVERSITY
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
INNER MONGOLIA UNIVERSITY
Filing Date
2025-04-30
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

Existing methods for generating combined test cases suffer from problems such as excessively large test case sets, numerous redundant test cases, low testing efficiency, and poor test quality.

Method used

An improved niche particle swarm optimization algorithm is adopted. By initializing the particles into a circular topology, the particle fitness is dynamically adjusted based on similarity measurement rules. Particle iteration is performed by combining distance and coverage radius to generate test case combinations.

Benefits of technology

Effectively control the size of the test case set, improve the efficiency and quality of test case generation, reduce testing costs, and enhance global search capabilities and coverage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120492333B_ABST
    Figure CN120492333B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a test case combination generation method, device, system, equipment and medium, relates to the technical field of combined test case generation, and the method comprises the following steps: initializing particles, and setting the structure between the particles as a ring topology structure; wherein each particle represents a test case; based on a set similarity measurement rule, the similarity between the particles is measured, and the fitness of the particles is dynamically adjusted; the fitness is iterated according to a set update rule; when the maximum iteration number is reached or all the parameter interaction combinations to be covered are covered, the iteration is stopped and the result is output; wherein the output result includes a global optimal solution or an approximate global optimal solution, and the output result is used as a newly generated test case; the efficiency and quality of test case generation are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of combined test case generation technology, and more specifically, to a method, apparatus, system, device, and medium for generating combined test cases. Background Technology

[0002] Existing combinatorial test case generation methods, such as Particle Swarm Optimization (PSO) and Genetic Algorithms (GA), rely on heuristic optimization methods and possess strong global search capabilities, enabling them to find high-coverage test case sets within a large input space. However, these algorithms typically focus on improving coverage and fail to effectively control the size of the test case set. Due to this lack of size control, the test case set often contains redundant test cases, resulting in a size exceeding actual requirements. This not only increases computational resources, storage space, and execution time but also raises testing costs and impacts testing efficiency, preventing the full execution of all test cases within a limited testing cycle, thus affecting test quality. Summary of the Invention

[0003] The purpose of this application is to provide a test case combination generation method, apparatus, system, device, and medium to solve the problems of low testing efficiency and poor testing quality in existing combined test case generation methods.

[0004] In a first aspect, embodiments of this application provide a test case combination generation method, applied to an automated testing platform, comprising:

[0005] Initialize the particles and set the structure between them to a circular topology; where each particle represents a test case.

[0006] Based on the established similarity measurement rules, the similarity between particles is measured, and the fitness of the particles is dynamically adjusted.

[0007] The fitness is iterated according to the set update rules;

[0008] The iteration stops and the results are output when the maximum number of iterations is reached or all parameter interaction combinations to be covered are covered. The output results include the global optimal solution or the near-global optimal solution, and the output results are used as newly generated test cases.

[0009] In the above implementation process, the embodiments of this application initialize particles and set the structure between particles as a circular topology; wherein, each particle represents a test case; based on the set similarity measurement rules, the similarity between particles is measured, and the fitness of the particles is dynamically adjusted; the fitness is iterated according to the set update rules; when the maximum number of iterations is reached or all parameter interaction combinations to be covered are covered, the iteration stops and the result is output; wherein, the output result includes the global optimal solution or the near-global optimal solution, and the output result is used as a newly generated test case; by operating the automated testing platform, based on the circular topology and similarity measurement rules, the fitness of the particles is dynamically adjusted, the fitness is dynamically adjusted, and test case combinations are generated, thereby improving the efficiency and quality of test case generation.

[0010] Furthermore, the dynamic adjustment of the particle fitness includes:

[0011] The fitness of a particle is weighted and adjusted based on the minimum distance between it and other particles in the population and the coverage radius.

[0012] When a particle has a large minimum distance and a small coverage radius, increase the particle's fitness.

[0013] When the minimum distance is small or the coverage radius is large, the fitness of the particle is reduced.

[0014] In the above implementation process, the fitness of particles is dynamically adjusted so that subsequent fitness adjustments can generate test case combinations.

[0015] Furthermore, the initialization of particles includes:

[0016] Initialize the position and velocity of the particles; where each particle represents a test case, and the position of each particle corresponds to a combination of parameter values ​​for a test case;

[0017] The historical best solution of each particle is initialized to the initial position of the particle, and the best solution in all particles is initialized to the global best solution;

[0018] Sort all particles according to their fitness and select the best individual as the first leader particle.

[0019] Centered on the leader particle, select several particles within a preset radius based on the cosine distance to form a small habitat together with the leader particle.

[0020] Remove all particles within the scope of this small student from the main population;

[0021] Repeat the process to select new leader particles and divide niches from the remaining particles until all particles have been assigned.

[0022] The particle with the best fitness in each niche is set as the corresponding local optimum.

[0023] In the above implementation process, the particle swarm is effectively initialized, which prepares for subsequent iterative optimization.

[0024] Furthermore, the measurement of similarity between particles based on the established similarity measurement rules includes:

[0025] Distance is used to measure the degree of difference between any two test cases in the coverage array; the larger the minimum distance, the more obvious the difference between the test cases.

[0026] The formula for calculating the minimum distance is as follows:

[0027] ;

[0028] Where C is the coverage array, which contains the test case set; x and y are any two test cases in the coverage array; This represents the distance metric between the two.

[0029] The coverage radius measures the coverage capability of a coverage array in the entire test space; a larger coverage radius indicates that the coverage array can cover more test cases.

[0030] The formula for calculating the coverage radius is as follows:

[0031] ;

[0032] Where g is the ideal point in the test space; x is any test case in the coverage array.

[0033] In the above implementation process, distance and coverage radius are used as important indicators for evaluating particle fitness in order to optimize the generation of test cases and ensure efficient test coverage with a small number of test cases.

[0034] Furthermore, the dynamic adjustment of the particle fitness includes:

[0035] The fitness of the particles is adjusted based on the minimum distance and coverage radius:

[0036] ;

[0037] in, For the original fitness, For the minimum distance, The coverage radius; and To set a constant.

[0038] In the above implementation process, fitness reflects the number of combinations covered by test cases, and the larger the value, the better the coverage effect.

[0039] Furthermore, the iterative process of fitness according to the set update rules includes:

[0040] If the particle's current fitness is better than the fitness of its historical best solution, then update the historical best solution to the particle's current position;

[0041] Calculate the fitness of each particle in each niche and compare it with the local optimum in the current niche; if the calculated fitness of the particle in the niche is better than the local optimum in the current niche, then update the local optimum in the current niche to the position of the calculated particle in the niche.

[0042] If the particle's current fitness is better than the fitness of its global optimum, then update the global optimum to the particle's current position.

[0043] Update particle velocity:

[0044] ;

[0045] in, This represents the best historical position of the i-th particle. This represents the best historical position of the i-th particle within its respective area;

[0046] Update particle positions:

[0047] ;

[0048] in, For position vectors, ;

[0049] in, For velocity vector, ;

[0050] in, and Let their positions and velocities at time t be represented respectively. and These are the updated position and velocity, respectively. Inertia weighting factor; and An acceleration factor greater than zero; ;

[0051] When updating the particle's position, a boundary check is performed to ensure that the particle's position is within the defined domain.

[0052] In the above implementation process, by adaptively adjusting the subgroup, it is ensured that the particles can fully explore the entire search space and avoid prematurely focusing on local optima. This not only enhances the global search capability but also improves the diversity and coverage of the test case set, thereby improving test quality and efficiency.

[0053] Secondly, embodiments of this application provide a test case combination generation device, integrated into an automated testing platform, comprising:

[0054] The particle initialization module is used to initialize particles and set the structure between particles to a circular topology; each particle represents a test case.

[0055] The particle measurement module is used to measure the similarity between particles based on the set similarity measurement rules and to dynamically adjust the fitness of the particles.

[0056] The iterative processing module is used to iterate the fitness according to the set update rules;

[0057] The test case output module is used to stop iteration and output results when the maximum number of iterations is reached or all parameter interaction combinations to be covered are covered. The output results include the global optimal solution or the near-global optimal solution, and the output results are used as newly generated test cases.

[0058] Thirdly, embodiments of this application provide a test case combination generation system, the test case combination generation system including an automated testing platform, the automated testing platform including: a test case combination generation module, a test case operation module, a visualization module, and a test case combination generation device as described above connected to the test case combination generation module;

[0059] The test case combination generation module is used for parameter input and algorithm selection; the test case operation module is used for parameter modification and deletion; and the visualization module is used to display test results and provide chart analysis.

[0060] Fourthly, embodiments of this application provide an electronic device, including:

[0061] The system includes a processor, a memory, and a bus. The processor is connected to the memory via the bus. The memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, they are used to implement the test case combination generation method described above.

[0062] Fifthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a server, implements the test case combination generation method described above. Attached Figure Description

[0063] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0064] Figure 1 A flowchart illustrating a test case combination generation method provided in an embodiment of this application;

[0065] Figure 2 This is a schematic diagram of the structure of a test case combination generation device provided in an embodiment of this application;

[0066] Figure 3 This is a schematic diagram of the software system functional structure of an automated testing platform provided in an embodiment of this application;

[0067] Figure 4 This is a schematic diagram of the overall software architecture design of an automated testing platform provided in an embodiment of this application;

[0068] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0069] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0070] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0071] Existing mainstream combinatorial test case generation algorithms, especially Particle Swarm Optimization (PSO), are important techniques based on heuristic optimization methods. PSO was first proposed to simulate flocks of birds and schools of fish searching for food through cooperative behavior, aiming to solve optimization problems. PSO finds the optimal solution by updating the positions of particles, making it suitable for solving combinatorial testing problems. This algorithm has strong search capabilities and can find a high-coverage test case set in a large-scale input space.

[0072] However, PSO typically focuses on improving coverage while lacking sufficient control over the size of the generated test case set, easily leading to redundant test cases. To address this, the QPSO algorithm is introduced for the first time. By updating particle positions through quantization, it improves global search capabilities and reduces the frequency of local optima. Subsequently, QPSO is applied to the field of generating variable-strength coverage tables for combined tests, integrating Lamarckian and Baldwinian learning methods to enhance the algorithm's performance, enabling it to generate coverage tables with strengths up to 15.

[0073] With the development of research, fitness sharing methods have emerged as another important diversity preservation technique. This method improves search diversity by adjusting the competitive relationships between individuals, thereby avoiding premature convergence of the algorithm. In recent years, many species-based optimization methods have been derived from the PSO algorithm, such as subtractive particle swarm optimization and speciesized particle swarm optimization. These methods avoid the generation of local optima by introducing adaptive subgroups into the particle swarm.

[0074] Regarding automated platforms for generating composite test cases, existing mainstream tools facilitate the generation and management of test cases. In 1992, Bell Labs developed the OATS tool, which uses orthogonal arrays to generate test cases. This mathematical model-based testing method can effectively reduce the number of test cases while ensuring comprehensive coverage of input parameters.

[0075] Furthermore, a one-dimensional expanding greedy strategy (OTAT) was proposed, and the Automatic Efficient Test Generator (AETG) tool was developed based on this strategy. OTAT constructs the test case set by progressively expanding it, optimizing generation efficiency while ensuring coverage. Column-by-column expansion (IPO) is another commonly used greedy algorithm, constructing test cases by parameter-by-parameter. Although it generates test cases quickly, the resulting test case set is large. Therefore, improved IPO algorithms, such as IPOG and IPOG-D, have been incorporated into the ACTS testing tool to further optimize test case generation.

[0076] In addition to these algorithms, some mathematically constructed methods are also widely used, such as tools like Testcover, Tconfig, and WHITCH. These tools utilize different mathematical models to improve the efficiency and adaptability of test case generation, and can meet a variety of different software testing needs.

[0077] In summary, existing combinatorial test case generation algorithms and automation platforms have achieved significant results in improving testing efficiency and coverage. However, current technologies still suffer from problems such as redundant test case generation, insufficient size control, and low automation levels, which increase testing costs and execution time. Therefore, effectively controlling the size of test cases and improving automation while ensuring test coverage remains a challenge in the field of combinatorial testing.

[0078] Based on this, this application proposes a test case combination generation method to solve the above problems.

[0079] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating a test case combination generation method provided in an embodiment of this application. (Refer to...) Figure 1 This test case combination generation method, applied to an automated testing platform, includes:

[0080] 100. Initialize the particles and set the structure between them to a circular topology; where each particle represents a test case.

[0081] Specifically, the particle positions and velocities are initialized; each particle represents a test case, and each particle's position corresponds to a combination of parameter values ​​for that test case. The historical best solution for each particle is initialized as its initial position, and the best solution among all particles is initialized as the global optimum. All particles are sorted by fitness, and the current best individual is selected as the first leader particle. Centered on this leader particle, several particles are selected within a preset radius based on cosine distance to form a niche with the leader particle. All particles within this niche are removed from the main swarm. This process is repeated, selecting new leader particles and dividing niches from the remaining particles until all particles are assigned. The particle with the best fitness in each niche is set as the corresponding local optimum. This effectively initializes the particle swarm, preparing it for subsequent iterative optimization.

[0082] 200. Based on the established similarity measurement rules, measure the similarity between particles and dynamically adjust the fitness of the particles.

[0083] Optionally, the fitness of a particle can be weighted and adjusted based on its minimum distance to other particles in the population and its coverage radius. When a particle has a larger minimum distance and a smaller coverage radius, its fitness is increased; when the minimum distance is small or the coverage radius is large, its fitness is decreased. Understandably, a larger minimum distance means the particle's minimum distance is greater than or equal to a set first distance threshold, and a smaller minimum distance means the particle's minimum distance is less than or equal to a set second distance threshold. Similarly, a smaller coverage radius means the particle's coverage radius is less than or equal to a set first radius threshold, and a larger coverage radius means the particle's coverage radius is greater than or equal to a set second radius threshold.

[0084] Optionally, adjust the fitness of particle calculations based on minimum distance and coverage radius:

[0085] ;

[0086] in, For the original fitness, For the minimum distance, The coverage radius; and To set a constant.

[0087] In the above implementation process, fitness reflects the number of combinations covered by test cases, and the larger the value, the better the coverage effect.

[0088] 300. Iterate the fitness according to the set update rules.

[0089] Optionally, if the particle's current fitness is better than the fitness of its historical best, then update the historical best to the particle's current position.

[0090] Calculate the fitness of each particle in each niche and compare it with the local optimum in the current niche; if the calculated fitness of the particle in the niche is better than the local optimum in the current niche, then update the local optimum in the current niche to the position of the calculated particle in the niche.

[0091] If a particle's current fitness is better than the fitness of its global optimum, then update the global optimum to the particle's current position.

[0092] Update particle velocity:

[0093] ;

[0094] in, This represents the best historical position of the i-th particle. This represents the best historical position of the i-th particle within its respective area;

[0095] Update particle positions:

[0096] .

[0097] in, For position vectors, .

[0098] in, For velocity vector, .

[0099] in, and Let their positions and velocities at time t be represented respectively. and These are the updated position and velocity, respectively. Inertia weighting factor; and An acceleration factor greater than zero; .

[0100] When updating the particle's position, a boundary check is performed to ensure that the particle's position is within the defined domain.

[0101] 400. When the maximum number of iterations is reached or all parameter interaction combinations to be covered are covered, the iteration stops and the results are output. The output results include the global optimal solution or the near-global optimal solution, and the output results are used as newly generated test cases.

[0102] As described above, in this embodiment, particles are initialized, and the structure between particles is set as a circular topology. Each particle represents a test case. Based on the set similarity measurement rules, the similarity between particles is measured, and the fitness of the particles is dynamically adjusted. The fitness is iterated according to the set update rules. When the maximum number of iterations is reached or all parameter interaction combinations to be covered are covered, the iteration stops and the results are output. The output results include the global optimal solution or the near-global optimal solution, and the output results are used as newly generated test cases. By operating an automated testing platform, the fitness of particles is dynamically adjusted based on the circular topology and similarity measurement rules. The dynamic adjustment of fitness generates test case combinations, improving the efficiency and quality of test case generation.

[0103] To address the issues of excessively large test case sets generated by traditional particle swarm optimization (PSO) algorithms and premature convergence of traditional niche PSO algorithms, this application introduces distance and coverage radius metrics and modifies the traditional topology structure into a ring topology to improve the niche PSO algorithm. This method reduces the size of the test case set and improves the efficiency of test case generation, thereby reducing testing costs and improving testing quality.

[0104] The improved niche particle swarm optimization algorithm in this application applies the principle of combinatorial testing: from all possible combinations of parameter values, a smaller set of test cases is selected to ensure that these test cases can cover all combinations of parameter values ​​required by the system.

[0105] Specifically, suppose there exists a SUT (System Under Test) containing n parameters, denoted as... , where each parameter The values ​​come from the set ,gather Includes Each element is a finite discrete set of points, which means that each parameter It can be obtained A discrete value. Let the set R represent the coverage requirement. If This means and Interactions between these elements can lead to software malfunctions. To cover... and this For each possible combination of values, multiple pairs of values ​​such as n-tuples are needed. The test cases are used to test the SUT. For simplicity, symbols are typically used. To describe, it can be simply referred to as , represents a coverage table, where N is the number of test cases, t represents the coverage level (the value of t is an integer between 1 and n), n is the number of parameters of the system under test, and d is the number of values ​​for each parameter.

[0106] The purpose of introducing the niche algorithm into test case generation is twofold: first, to guide the population to explore the solution space in diverse ways, thereby increasing the likelihood of finding the global optimum; and second, to prevent premature convergence and enhance global search capabilities. Specifically, a shared function is introduced to measure the similarity between individuals, and this function is used to adjust fitness values: when an individual is similar to other individuals, its fitness value is penalized; conversely, it is rewarded. The specific test case combination generation process is as follows:

[0107] Particle initialization. Initialize the particle positions. and speed Each particle represents a test case. The position of each particle corresponds to a combination of parameter values ​​for a test case. The historical optimal solution for each particle is also represented. Initialize to the initial position of the particles. Initialize the global optimal solution. Let represent the optimal solution among all particles. Initialize the local optimum of the niche. Record the best solution in each niche.

[0108] Distance calculation. Distance metrics are used to assess the similarity between particles and the diversity of a population, helping to maintain population diversity and prevent particle populations from converging to the same solution region. This application's embodiments utilize several distance algorithms in their implementation: Euclidean distance, which calculates the "straight-line" distance between two particles, measuring the differences between particles in multidimensional space, is expressed by the formula: Where x and y are the two positions of the particle, and n is the particle's dimension. The Manhattan distance measures the sum of the absolute differences of the particle in each dimension, and is expressed by the formula: Where x and y are the two positions of the particle, and n is the particle's dimension. Cosine similarity calculates the angular similarity between particles to assess their similarity, measuring the directional differences between particles. The formula is: Where x and y are the two positions of the particle, and n is the dimension of the particle.

[0109] The application of these distance metrics enables particle swarms to maintain diversity and avoid over-convergence.

[0110] Applications of distance. Distance and coverage radius This is used as an important metric for evaluating particle fitness to optimize test case generation and ensure efficient test coverage with a smaller number of test cases. By measuring the distance between particles, test cases in the coverage array, and the coverage radius, the algorithm can dynamically adjust the search direction of the particle swarm, rewarding particles and test cases in the coverage array that are relatively far away and have a large coverage radius, and penalizing particles with the opposite distance, thereby optimizing the size and quality of the test case set.

[0111] Distance measures the degree of difference between any two test cases in the coverage array. A larger minimum distance indicates more significant differences between test cases, meaning the test cases can cover more diverse defects, thus enhancing the comprehensiveness of the testing. The formula for calculating the minimum distance is as follows: Where: C is the coverage array, containing the test case set; x and y are any two test cases in the coverage array; This represents the distance metric between the two.

[0112] Coverage radius measures the coverage capability of a coverage array across the entire test space. A larger coverage radius indicates that the coverage array can cover more test cases, thus improving the comprehensiveness and efficiency of testing. Its calculation formula is as follows: Where: g is the ideal point in the test space, which is usually the optimal solution covering all possible test scenarios; x is any test case in the coverage array.

[0113] Fitness calculation. The fitness value measures the coverage effect of a test case in the combined coverage state table. The fitness value is initialized to 0, and then all parameter value combinations are traversed lexicographically. For each combination, its position in the state table is calculated; if the value at that position is 1, the fitness value is incremented by 1. Ultimately, the fitness value reflects the number of combinations covered by the test case; a higher value indicates better coverage.

[0114] The fitness of the particles is adjusted based on the minimum distance and coverage radius:

[0115] ;

[0116] in, For the original fitness, For the minimum distance, The coverage radius; and To set a constant.

[0117] Combined Coverage Status Table or It is an N×n matrix structure with a range of size l. Any N×t submatrix in the matrix can contain all permutations of size t over the range l. Here, N represents the number of test cases; t represents the test strength; n represents the degree, i.e., the number of factors in the system; and l represents the order, i.e., the number of values ​​for each factor. For example, the SUT in the combined coverage state table can be represented as CA(9;2,4,3) or CA(9;2, N can also be omitted. Furthermore, a covering array with the smallest number of rows is considered the optimal covering array, and the smallest number of rows it contains is named the Covering Array Number (CAN).

[0118] Update historical optimal solution ( If the particle's current fitness Fitness better than its historical best Then update the historical best solution. Let x be the current position of the particle.

[0119] Update local optimal solution ( For each niche, calculate the fitness of each particle and compare it with the optimal solution within the current niche. The comparison is performed. If the particle has better fitness, the local optimum of that niche is updated.

[0120] Update the global optimal solution ( If the particle's current fitness Fitness better than its historical best Then update the global optimal solution. This represents the current position of the particle.

[0121] Velocity and position updates. Update particle velocity:

[0122] ;

[0123] in, This represents the best historical position of the i-th particle. This represents the best historical position of the i-th particle within its respective area;

[0124] Update particle positions:

[0125] ;

[0126] in, For position vectors, ;

[0127] in, For velocity vector, ;

[0128] in, and Let their positions and velocities at time t be represented respectively. and These are the updated position and velocity, respectively. Inertia weighting factor; and An acceleration factor greater than zero; When updating the particle's position, a boundary check is performed to ensure that the particle's position is within the defined domain.

[0129] Topology. A circular topology is used, where each particle exchanges information only with its immediate and adjacent neighbors. Circular topology effectively increases the diversity of the population, preventing particles from becoming overly dependent on other particles and thus preventing premature convergence.

[0130] Stopping condition. The algorithm stops when the maximum number of iterations is reached or all parameter combinations to be covered are covered.

[0131] Output test cases. The final output includes the globally optimal solution or a near-globally optimal solution, which serves as the optimal combination of test cases.

[0132] The steps described above are not strictly performed in the order of their numbers; they should be understood as a whole.

[0133] Secondly, based on the above embodiments, Figure 2 This is a schematic diagram of a test case combination generation device provided in an embodiment of this application. (Reference) Figure 2 The test case combination generation device provided in this embodiment is integrated into an automated testing platform, specifically including: a particle initialization module 201, a particle measurement module 202, an iteration processing module 203, and a test case output module 204.

[0134] The particle initialization module 201 initializes particles and sets the structure between particles to a circular topology; each particle represents a test case; the particle measurement module 202 measures the similarity between particles based on the set similarity measurement rules and dynamically adjusts the fitness of the particles; the iteration processing module 203 iterates the fitness according to the set update rules; the test case output module 204 stops the iteration and outputs the results when the maximum number of iterations is reached or all parameter interaction combinations to be covered are covered; the output results include the global optimal solution or the near-global optimal solution, and the output results are used as newly generated test cases.

[0135] As described above, in this embodiment, particles are initialized, and the structure between particles is set as a circular topology. Each particle represents a test case. Based on the set similarity measurement rules, the similarity between particles is measured, and the fitness of the particles is dynamically adjusted. The fitness is iterated according to the set update rules. When the maximum number of iterations is reached or all parameter interaction combinations to be covered are covered, the iteration stops and the results are output. The output results include the global optimal solution or the near-global optimal solution, and the output results are used as newly generated test cases. By operating an automated testing platform, the fitness of particles is dynamically adjusted based on the circular topology and similarity measurement rules. The dynamic adjustment of fitness generates test case combinations, improving the efficiency and quality of test case generation.

[0136] This application's embodiments are based on an improved niche particle swarm optimization (PSO) algorithm. By optimizing population distribution, introducing a distance metric mechanism, and employing a dynamic search strategy and circular topology, it enhances the efficiency and quality of test case generation. The niche mechanism effectively prevents excessive concentration of individuals, reducing redundant test cases. The distance metric strategy calculates the similarity between test cases, dynamically adjusts the population distribution, improves coverage, and optimizes scale. The search strategy enhances global exploration in the early stages and refines local searches in the later stages, ensuring that the generated test cases are both comprehensive and compact. Furthermore, the algorithm can automatically adjust inertia weights based on test data characteristics, improving search stability, avoiding meaningless redundancy, and reducing testing costs.

[0137] The test case combination generation device provided in this application embodiment can be used to execute the test case combination generation method provided in the above embodiment, and has corresponding functions and beneficial effects.

[0138] Thirdly, embodiments of this application provide a test case combination generation system. This system includes an automated testing platform, comprising: a test case combination generation module, a test case operation module, a visualization module, and a test case combination generation device as described above connected to the test case combination generation module. The test case combination generation module is used for parameter input and algorithm selection; the test case operation module is used for parameter modification and parameter deletion; and the visualization module is used to display test results and provide chart analysis.

[0139] Optionally, an interface testing module is also included for test case modeling and interface testing.

[0140] The automated testing platform (tool) features a front-end developed using Vue3 and Electron, supporting cross-platform use for both web and desktop applications. The back-end is built using Node.js and stores data in a MySQL database. The software can display generated test case sets and interface with API testing systems to automatically execute API tests, verifying the correctness and performance of the interfaces. The tool also provides data analysis and visualization charts to help users evaluate test coverage and performance, improving testing efficiency.

[0141] For example, the overall architecture is as follows Figure 3 As shown, the front-end is written using Vue3 and Electron, with Chromium as the core, supporting both web pages and desktop applications. The back-end is built using Node.js, and the database is a relational database MySQL. The niche particle swarm optimization algorithm is written in C++ and called through the Child_process module in Node.js.

[0142] This application's implementation uses Vue 3 and Electron for the front-end. Vue 3 provides a high-performance reactive system and Composition API, improving performance and maintainability. Electron, combined with Chromium and Node.js, supports cross-platform desktop application development, achieving seamless integration between the web and desktop. The back-end uses Node.js, leveraging its high concurrency capabilities to build API services, improving system performance and scalability. MySQL is used for data storage to handle test cases and results, ensuring data integrity and query efficiency. Redis is used as a cache to optimize real-time data access and improve system response speed.

[0143] The main business processes of this automated testing platform are designed as follows:

[0144] 1) Users (test staff) enter basic information about the test cases in the test case template, including coverage strength, number of parameters, coverage location, etc.;

[0145] 2) Users can initiate the test case generation function through the operation interface in the test case template;

[0146] 3) The user interface transmits user commands to the internal analysis and processing module;

[0147] 4) The system internally analyzes and processes the combination rules description of the module reading factors;

[0148] 5) After system analysis, the internal algorithm is invoked to generate combined test cases, which are then displayed.

[0149] 6) Test results are displayed in tabular form, with support for custom sorting;

[0150] 7) Users can view specific test data and obtain detailed analysis, including test time, specific algorithms, and a graph showing the relationship between the number of tests and coverage. The software system flow of this automated testing platform is as follows: Figure 4 As shown: Start operation; Select function; If no data is available, add data for hyperparameter optimization, create a background subprocess to call the algorithm, obtain test cases, obtain result table; If data already exists, select to generate relevant parameters or generate data table; Enter the sequence number according to the result table to obtain the result; Test case modeling; Test case mapping; Obtain test results.

[0151] The automated testing platform features a modular software business design, primarily including modules for user information, test case generation, statistical table generation, and data analysis. User Information: This module allows users to customize their basic information, including avatar, nickname, gender, and region. Changes automatically update the avatar and nickname. Test Case Generation: This module supports parameter management and test result visualization. Users can add, modify, and delete parameters to generate combined test cases, which are displayed in the input order. The operation column includes "Modify" and "Delete" buttons, supporting automatic sorting after parameter adjustment or data deletion, simplifying the operation process and database management, and improving the flexibility and maintainability of test case generation. Statistical Table Generation: This module displays selected data rows, supports sorting by specific columns, and provides Excel export functionality. Users can filter data by serial number, sort, and click export; the system automatically saves it as an Excel file, improving data management and sharing efficiency. Data Analysis: This module provides detailed analysis of selected test cases, including the number of generated tests, execution time, number of combined tests, algorithm used, and a function graph showing the relationship between coverage and the number of generated tests, providing testers with intuitive performance evaluation and data visualization support.

[0152] Fourthly, embodiments of this application also provide an electronic device that can integrate the test case combination generation device provided in embodiments of this application. Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. (Reference) Figure 5 The electronic device includes: an input device 43, an output device 44, a memory 42, and one or more processors 41; the memory 42 is used to store one or more programs; when the one or more programs are executed by the one or more processors 41, the one or more processors 41 implement the test case combination generation method provided in the above embodiments. The input device 43, output device 44, memory 42, and processor 41 can be connected via a bus or other means. Figure 5 Taking the example of a connection between China and Israel via a bus.

[0153] The processor 41 executes various functional applications and data processing of the device by running software programs, instructions and modules stored in the memory 42, thereby realizing the above-mentioned test case combination generation method.

[0154] The electronic device provided above can be used to execute the test case combination generation method provided in the above embodiments, and has corresponding functions and beneficial effects.

[0155] Fifthly, embodiments of this application also provide a computer-readable storage medium, which includes a stored computer program; wherein, when the computer program is running, it controls the device where the computer-readable storage medium is located to execute the test case combination generation method as described above, and can achieve the same beneficial effects.

[0156] Of course, the computer-executable instructions provided in the embodiments of this application are not limited to the test case combination generation method described above, but can also execute related operations in the test case combination generation method provided in any embodiment of this application.

[0157] The computer program or instructions may be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another. For example, the computer program or instructions may be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The computer-readable storage medium may be any available medium that a computer can access, or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; or an optical medium, such as a digital video optical disc; or a semiconductor medium, such as a solid-state drive. The computer-readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.

[0158] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0159] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0160] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0161] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0162] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

Claims

1. A method for generating test case combinations, characterized in that, Applications in automated testing platforms include: Initialize the particles and set the structure between them to a circular topology; where each particle represents a test case. Based on the established similarity measurement rules, the similarity between particles is measured, and the fitness of the particles is dynamically adjusted. The dynamic adjustment of particle fitness includes: weighted correction of the particle's fitness based on the minimum distance and coverage radius between the particle and other particles in the population; increasing the particle's fitness when the minimum distance is large and the coverage radius is small; decreasing the particle's fitness when the minimum distance is small or the coverage radius is large. Wherein, a large minimum distance means the particle's minimum distance is greater than or equal to a set first distance threshold, and a small minimum distance means the particle's minimum distance is less than or equal to a set second distance threshold, where the first distance threshold is greater than the second distance threshold; a small coverage radius means the particle's coverage radius is less than or equal to a set first radius threshold, and a large coverage radius means the particle's coverage radius is greater than or equal to a set second radius threshold, where the first radius threshold is less than the second radius threshold. The fitness is iterated according to the set update rules; The iteration stops and the results are output when the maximum number of iterations is reached or all parameter interaction combinations to be covered are covered. The output results include the global optimal solution or the near-global optimal solution, and the output results are used as newly generated test cases.

2. The test case combination generation method according to claim 1, characterized in that, The initialization particles include: Initialize the position and velocity of the particles; where each particle represents a test case, and the position of each particle corresponds to a combination of parameter values ​​for a test case; The historical best solution of each particle is initialized to the initial position of the particle, and the best solution in all particles is initialized to the global best solution; Sort all particles according to their fitness and select the best individual as the first leader particle. Centered on the leader particle, select several particles within a preset radius based on the cosine distance to form a small habitat together with the leader particle. Remove all particles within the scope of this small student from the main population; Repeat the process to select new leader particles and divide niches from the remaining particles until all particles have been assigned. The particle with the best fitness in each niche is set as the corresponding local optimum.

3. The test case combination generation method according to claim 1, characterized in that, The method of measuring the similarity between particles based on the set similarity measurement rules includes: Distance is used to measure the degree of difference between any two test cases in the coverage array; the larger the minimum distance, the more obvious the difference between the test cases. The formula for calculating the minimum distance is as follows: ; Where C is the coverage array, which contains the test case set; x and y are any two test cases in the coverage array; This represents the distance metric between the two. The coverage radius measures the coverage capability of a coverage array in the entire test space; a larger coverage radius indicates that the coverage array can cover more test cases. The formula for calculating the coverage radius is as follows: ; Where g is the ideal point in the test space; x is any test case in the coverage array.

4. The test case combination generation method according to claim 1, characterized in that, The dynamic adjustment of the particle fitness includes: The fitness of the particles is adjusted based on the minimum distance and coverage radius: ; in, For the original fitness, For the minimum distance, The coverage radius; and To set a constant.

5. The test case combination generation method according to claim 1, characterized in that, The iterative process of fitness according to the set update rules includes: If the particle's current fitness is better than the fitness of its historical best solution, then update the historical best solution to the particle's current position; Calculate the fitness of each particle in each niche and compare it with the local optimum in the current niche; if the calculated fitness of the particle in the niche is better than the local optimum in the current niche, then update the local optimum in the current niche to the position of the calculated particle in the niche. If the particle's current fitness is better than the fitness of its global optimum, then update the global optimum to the particle's current position. Update particle velocity: ; in, This represents the best historical position of the i-th particle. This represents the best historical position of the i-th particle within its respective area; Update particle positions: ; in, For position vectors, ; in, For velocity vector, ; in, and Let their positions and velocities at time t be represented respectively. and These are the updated position and velocity, respectively. Inertia weighting factor; and An acceleration factor greater than zero; ; When updating the particle's position, a boundary check is performed to ensure that the particle's position is within the defined domain.

6. A test case combination generation device, characterized in that, Integrated into automated testing platforms, including: The particle initialization module is used to initialize particles and set the structure between particles to a circular topology; each particle represents a test case. The particle measurement module is used to measure the similarity between particles based on a set similarity measurement rule and dynamically adjust the fitness of particles. The dynamic adjustment of particle fitness includes: weighting the fitness of a particle based on its minimum distance to other particles in the population and its coverage radius; increasing the fitness of a particle when its minimum distance is large and its coverage radius is small; and decreasing the fitness of a particle when its minimum distance is small or its coverage radius is large. Wherein, a large minimum distance means the particle's minimum distance is greater than or equal to a set first distance threshold, and a small minimum distance means the particle's minimum distance is less than or equal to a set second distance threshold, where the first distance threshold is greater than the second distance threshold; a small coverage radius means the particle's coverage radius is less than or equal to a set first radius threshold, and a large coverage radius means the particle's coverage radius is greater than or equal to a set second radius threshold, where the first radius threshold is less than the second radius threshold. The iterative processing module is used to iterate the fitness according to the set update rules; The test case output module is used to stop iteration and output results when the maximum number of iterations is reached or all parameter interaction combinations to be covered are covered. The output results include the global optimal solution or the near-global optimal solution, and the output results are used as newly generated test cases.

7. A test case combination generation system, characterized in that, The test case combination generation system includes an automated testing platform, which includes: a test case combination generation module, a test case operation module, a visualization module, and a test case combination generation device as described in claim 6 connected to the test case combination generation module; The test case combination generation module is used for parameter input and algorithm selection; the test case operation module is used for parameter modification and deletion; and the visualization module is used to display test results and provide chart analysis.

8. An electronic device, characterized in that, include: The processor, memory, and bus are provided, wherein the processor is connected to the memory via the bus, and the memory stores computer-readable instructions that, when executed by the processor, are used to implement the test case combination generation method as described in any one of claims 1-5.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by the server, implements the test case combination generation method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Multi-modal feature selection method based on particle swarm algorithm

    CN111723897A

  • Industrial big data multi-modal feature selection method and device, equipment and medium

    CN117093844A

  • Automatic test case generation method based on large model and particle swarm optimization

    CN119271565A