Method, system and device for automatically producing interface test cases

Search through the dynamic constructing rules set and combined with a variety of inspiration algorithms to generate the ATP interface test case, solve the problem of low efficiency and low coverage in existing technologies, and achieve more efficient test case generation and better coverage Rate.

CN118860903BActive Publication Date: 2025-01-24CRSC RESEARCH & DESIGN INSTITUTE GROUP CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411336549.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-25
Publication Date
2025-01-24
Estimated Expiration
2044-09-25

AI Technical Summary

Technical Problem

When generating ATP interface test cases, the prior art is inefficient and has low coverage, making it difficult to effectively detect software defects and vulnerabilities.

Method used

Through dynamically construct preset rules, establish a dynamic coverage process, generate initial types, and combine the genetic algorithm, simulation annealing algorithm and taboo search algorithm for global and local search, iterated to generate test cases, and adapted adjustment.

Benefits of technology

It improves the efficiency and coverage of test case generation, reduces the number of case generation, improves test coverage, and can discover ATP software defects and vulnerabilities faster.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118860903B_ABST
    Figure CN118860903B_ABST
Patent Text Reader

Abstract

The present disclosure belongs to the field of train control, and proposes a method, system and device for automatically generating interface test cases. The method includes: dynamically constructing a preset rule set according to the interface parameter relationship and weight, and establishing a dynamic coverage process according to the preset rule set; generating an initial population according to the dynamic coverage process, and combining a variety of heuristic algorithms to perform global search and local search on the initial population, and iteratively generating test cases. The present disclosure reduces the search space of the generation process and improves the generation efficiency by adaptively combining the associated constraint relationship, priority, etc. in the ATP interface parameter requirements; and combines the advantages of efficient global search algorithms and local search and enhancement algorithms to accelerate convergence while avoiding falling into local optimality, thereby improving the test coverage of the solution; at the same time, the present disclosure dynamically and adaptively adjusts the parameters in the generation process according to information such as iteration cycle, dynamic coverage, and internal feedback, so as to balance the solution time and solution quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure belongs to the field of train control, and in particular relates to an automatic production method, system and device for interface test cases. Background Art

[0002] The on-board ATP (Automatic Train Protection) system (hereinafter referred to as ATP) is one of the core components of the train control system. Its various data input interfaces are also an important part of the system security. The ATP interface input is complex, and it is time-consuming and laborious to use exhaustive methods or manual writing for its test cases. The existing automatic generation methods are difficult to guarantee good results in terms of generation efficiency and test coverage, which brings certain difficulties to the subsequent discovery of ATP software defects and vulnerabilities. Summary of the invention

[0003] In view of the above problems, the present disclosure proposes a method for automatically generating interface test cases, the method comprising:

[0004] Dynamically construct a preset rule set according to the interface parameter relationship and weight, and establish a dynamic coverage process according to the preset rule set;

[0005] An initial population is generated according to a dynamic coverage process, and a variety of heuristic algorithms are combined to perform global and local searches on the initial population to iteratively generate test cases.

[0006] Furthermore, establishing a dynamic coverage process according to the preset rule set includes:

[0007] Determine parameter priority and preset initial coverage strategy for interface parameters;

[0008] Determine the parameter association relationship, update the priority according to the specific combination weight and specific combination value, and equally divide and replace the associated parameters;

[0009] Determine parameter constraint relationships, exclude invalid test cases, and discard, flip, or partially replace parameter combinations based on preset mutually exclusive parameter sets.

[0010] Furthermore, combining multiple heuristic algorithms to perform global and local searches on the initial population includes:

[0011] Dynamic coverage global search based on genetic algorithm;

[0012] Perform local search on the individual solution space based on simulated annealing algorithm;

[0013] The individuals are adaptively checked and the solution space is updated based on a taboo search algorithm.

[0014] Furthermore, the method also includes the step of adaptively adjusting the iteratively generated test cases.

[0015] Furthermore, the adaptive adjustment includes:

[0016] By normalizing the initial population fitness function and sharing individual fitness;

[0017] Dividing the number of iterations of each type of heuristic algorithm into the early iteration, the middle iteration, and the late iteration;

[0018] The initial group of shared individual fitness is adaptively adjusted in turn during the partitioning iterations according to various types of heuristic algorithms.

[0019] Further, performing adaptive adjustment during the division iteration number according to the genetic algorithm includes:

[0020] At the beginning of iteration, the first crossover frequency and the first mutation frequency are used in combination with the individual fitness coefficient for uniform crossover, and the best is selected after random mutation;

[0021] In the middle / late stages of iteration, the second crossover frequency and the second mutation frequency are used in combination with multi-point crossover of individual fitness coefficients, and the best is selected after segmented mutation;

[0022] The first crossover frequency is higher than the second crossover frequency, and the first mutation frequency is higher than the second mutation frequency.

[0023] Further, performing adaptive adjustment during the partitioning iteration number according to the simulated annealing algorithm includes:

[0024] In the early stage of iteration, the optimal solution set is slowly cooled down and the neighborhood solution is generated through the first step, and the suboptimal solution is accepted with the first probability;

[0025] In the middle / late stage of iteration, the optimal solution set is cooled down quickly and a neighborhood solution is generated through the second step length, and the suboptimal solution is accepted with the second probability;

[0026] Among them, the first step length is greater than the second step length, and the first probability is higher than the second probability.

[0027] Further, the adaptive adjustment during the partitioning iteration number according to the tabu search algorithm includes:

[0028] In the early stage of iteration, the first taboo table is used and the acceptance rate is combined to adjust the diversity;

[0029] In the middle of the iteration, the second and third taboo tables are used to adjust diversity together;

[0030] In the later stage of iteration, a hierarchical taboo table is used in combination with dynamic covering to retain the optimal solution and reduce the length of the taboo table.

[0031] Furthermore, the initial stage of iteration also includes the step of dividing the population and retaining the optimal solution of the previous part of each group before performing adaptive adjustment;

[0032] In the middle and later stages of iteration, before making adaptive adjustments, the step of retaining the optimal solution of the previous part of the population in combination with dynamic coverage is also included.

[0033] The present disclosure also provides an interface test case automatic generation system, the system comprising a construction unit and a generation unit,

[0034] A construction unit, used to dynamically construct a preset rule set according to the interface parameter relationship and weight, and establish a dynamic coverage process according to the preset rule set;

[0035] The generation unit is used to generate an initial population according to a dynamic coverage process, and to perform global and local searches on the initial population in combination with a variety of heuristic algorithms to iteratively generate test cases.

[0036] Furthermore, the construction unit includes a first determination module, a second determination module and a third determination module.

[0037] The first determination module is used to determine the parameter priority and preset the initial coverage strategy of the interface parameters;

[0038] The second determination module is used to determine the parameter association relationship, update the priority according to the specific combination weight and the specific combination value, and equivalently divide and replace the associated parameters;

[0039] The third determination module is used to determine the parameter constraint relationship, exclude invalid test cases, and discard, flip, and partially replace parameter combinations according to preset exclusive parameter sets.

[0040] Furthermore, the system also includes an adjustment unit for performing adaptive adjustment on the iteratively generated test cases.

[0041] Furthermore, the adjustment unit includes a normalization module, a division module and an adjustment module.

[0042] Normalization module, used to normalize the initial population fitness function and share individual fitness;

[0043] A division module is used to divide the number of iterations of each type of heuristic algorithm, wherein the number of iterations is divided into an early iteration, a middle iteration, and a late iteration;

[0044] The adjustment module is used to adaptively adjust the initial group of shared individual fitness in turn according to various types of heuristic algorithms during the division of the number of iterations.

[0045] The present disclosure also provides an electronic device, the electronic device comprising at least one processor and at least one memory, the memory being data-connected to the processor, wherein:

[0046] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any of the above methods of the present disclosure.

[0047] The disclosed automatic production method, system and device of interface test cases are adaptively combined with the associated constraint relationship, priority and the like in the ATP interface parameter requirements, so as to reduce the search space of the generation process and improve the generation efficiency; and combined with the advantages of efficient global search algorithm and local search and enhancement algorithm, it can avoid falling into the local optimum while accelerating convergence, and improve the test coverage of the solution; at the same time, the disclosed method dynamically and adaptively adjusts the parameters in the generation process according to the information such as iteration cycle, dynamic coverage and internal feedback, so as to balance the solution time and solution quality. It can flexibly combine the parameter preset conditions such as parameter weight, associated relationship and constraint relationship, dynamically and adaptively adjust the case algorithm generation algorithm, reduce the number of case generation, and improve the test coverage.

[0048] Other features and advantages of the present disclosure will be described in the following description, and partly become apparent from the description, or be understood by implementing the present disclosure. The purpose and other advantages of the present disclosure can be realized and obtained by the structures pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0050] Figure 1 A schematic diagram of the process of automatically generating interface test cases in an embodiment of the present disclosure is shown;

[0051] Figure 2 A schematic diagram of a dynamic coverage process in an embodiment of the present disclosure is shown;

[0052] Figure 3 A schematic diagram of a hybrid search method based on a heuristic algorithm in an embodiment of the present disclosure is shown;

[0053] Figure 4 A schematic diagram of the process flow of the adaptive operator adjustment and acceptance strategy adjustment method in the embodiment of the present disclosure is shown;

[0054] Figure 5 A schematic diagram of the structure of an automatic generation system for interface test cases in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0055] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.

[0056] The input of ATP interface is complex, and it is time-consuming and laborious to use exhaustive method or manual writing for its test cases. The present invention can combine more efficient generation algorithm according to the characteristics of ATP interface parameters, greatly reduce the number of generated cases, ensure higher coverage, and greatly improve the efficiency and quality of automated testing.

[0057] Figure 1 The following is a flow chart of the method for automatically generating interface test cases in an embodiment of the present disclosure. Figure 1 In the method, a preset rule set is dynamically constructed according to the interface parameter relationship and weight, and a dynamic coverage process is established according to the preset rule set; an initial population is generated according to the dynamic coverage process, and a global search and a local search are performed on the initial population in combination with a plurality of heuristic algorithms to iteratively generate test cases. The method also includes the step of adaptively adjusting the test cases generated iteratively. Specifically, the method disclosed herein integrates a dynamic coverage method based on the ATP interface parameter association constraint relationship, a hybrid search method based on a heuristic algorithm, an adaptive operator adjustment and an acceptance strategy adjustment method to automatically generate vehicle-mounted ATP interface test cases.

[0058] In this embodiment, the following steps of the method for automatically generating interface test cases disclosed in the present invention are described in detail:

[0059] In the present disclosure, the dynamic coverage process is established according to the preset rule set, including: determining parameter priority, presetting the initial coverage strategy of interface parameters; determining parameter association, updating priority according to specific combination weights and specific combination values, and equivalently dividing and replacing associated parameters; determining parameter constraint relationships, excluding invalid test cases, and discarding, flipping, and partially replacing parameter combinations according to preset mutually exclusive parameter sets. Based on the priority, association, constraint relationship and other constraints of interface parameters, the generation formula is preset to improve the generation efficiency. Figure 2 A schematic diagram of a dynamic coverage process in an embodiment of the present disclosure is shown. Figure 2 Specifically include:

[0060] (1) A rule set is established for parameters according to ATP interface parameter-related standards, test requirements, industry experience, etc. In the embodiments of the present disclosure, the parameter relationship includes parameter priority, parameter association relationship, parameter constraint relationship, etc. It should be noted that the description of parameter relationship in the present disclosure is only an exemplary description. Without departing from the technical concept of the present disclosure, changes only to the parameter association relationship are also within the protection scope of the present disclosure.

[0061] (2) Determine whether the ATP interface parameters have priorities. Based on the parameter priorities, different and variable coverage strengths can be preset.

[0062] In the embodiment of the present disclosure, the coverage of interface parameters is described. Taking the conventional ATP interface parameters as an example, according to the security level, there are 12 security-related parameters and 18 non-security-related parameters. Therefore, P0-P 11 Using 3-way coverage strength, P 12 -P 29 An initial coverage strategy with 2-way coverage strength is adopted;

[0063] In the disclosed embodiment, the initial coverage strategy is only an example, including but not limited to this variable coverage strength, and the coverage strength can be dynamically allocated according to demand, expert experience, and application conditions in actual scenarios. For example, parameter weight adjustment, phased generation strategy, and rule-based dynamic adjustment;

[0064] Among them, the phased generation strategy: the initial stage generates basic 2-way coverage test cases. In the subsequent stages, some important parameter combinations are identified and the coverage strength of these combinations is gradually increased. Dynamic adjustment based on rules: if the value combination of some parameters is within a specific range, the coverage strength is increased.

[0065] (3) Determine whether there is a correlation between parameters. Based on the correlation between parameters, first, some specific parameter combinations can be given higher weights. Secondly, based on preset rules, the associated parameters can be divided and replaced equivalently. For example, based on the rule that when P7 or P8 is 1, one of P0 or P1 must be 1, then when covering P7 or P8, the value of P0 or P1 does not need to be repeatedly covered.

[0066] (4) Determine whether there is a constraint relationship between parameters. Based on the constraint relationship between parameters, firstly, we can exclude parameter combinations that cannot take the same value at the same time to avoid generating invalid or illegal test cases, thereby reducing the number of invalid test cases. Secondly, during the generation process, if invalid values ​​are found in the early stage, we can terminate it as soon as possible. If invalid values ​​or other values ​​with strong adaptability are found in the later stage, we can choose to flip the invalid value parameters or adopt a partial replacement strategy.

[0067] In the present disclosure, a preset rule base is dynamically constructed according to the relationship and weight between parameters, and a coverage method with variable strength is established to prepare for the subsequent generation of test cases.

[0068] In this disclosure, coverage strength is used to describe the degree to which test cases cover system input parameter combinations, and refers to the size of the subset of all possible combinations of input parameters covered by the test cases. For example: 2-way coverage: test cases cover all possible pairwise combinations of input parameters. This is the most commonly used coverage strength, because many defects are often caused by interactions between two parameters.

[0069] Variable strength coverage aims to optimize the use of test resources and improve test efficiency and effectiveness by flexibly selecting the coverage strength of different subsets. In practical applications, the interaction between different parameters may have different effects on system behavior. Variable strength coverage allows different coverage strengths to be applied to different parameter subsets, thereby allocating test resources more flexibly.

[0070] Dynamic coverage refers to the adaptive adjustment of the coverage strength of each parameter based on the test requirements and some feedback during the algorithm execution process. Different from variable strength coverage, dynamic coverage is the adjustment of the coverage strategy during the algorithm execution process. Variable strength coverage generally presets the parameter coverage strength and will not be modified during the calculation process.

[0071] In the present disclosure, a global search and a local search are performed on the initial population by combining a variety of heuristic algorithms. The heuristic algorithms in the present disclosure select genetic algorithms (GA), simulated annealing algorithms (SA), and tabu search algorithms (TS). Dynamic coverage global search is performed based on genetic algorithms; local search is performed on individual solution spaces based on simulated annealing algorithms; and adaptive inspection of the individuals is performed and the solution space is updated based on tabu search algorithms. It should be noted that the selection of the type of heuristic algorithm in the present disclosure is only an exemplary description. Without departing from the concept of the present disclosure, changes only to the type of heuristic algorithm are also within the scope of protection of the present disclosure.

[0072] In combinatorial optimization problems, the present disclosure combines multiple heuristic algorithms to effectively balance the speed and accuracy of global and local searches. The present disclosure combines genetic algorithms, simulated annealing algorithms, and taboo search algorithms, and performs dynamic coverage based on satisfying complex constraints to more efficiently explore the solution space. Figure 3 The figure shows a flow chart of a hybrid search method based on a heuristic algorithm in an embodiment of the present disclosure. Figure 3 In , the specific hybrid search process is as follows:

[0073] (1) Initial population generation: Based on the characteristic that the parameters are Boolean variables, binary coding is used to represent the solution to the problem. According to the coding scheme and the dynamic coverage method in the previous part, a certain number of individuals are generated according to the coverage range and coverage strength to form the initial population. Each individual represents a possible solution.

[0074] (2) GA global search: Use GA to perform global search, select high-quality individuals through fitness function F1, and use crossover probability P c Perform crossover to generate new individuals with a mutation probability P m Mutation is performed to increase diversity, and a new population is formed from selected, crossover, and mutated individuals, which replace the old population after a dynamic coverage check to explore different areas of the solution space.

[0075] (3) SA local search: In the solution space generated and retained in GA, select a certain proportion of high-quality individuals S and use SA for local optimization. Set the initial temperature for each selected individual, the temperature control strategy F2, and the probability of accepting a poor solution P exp After that, the iteration begins, and the strategy F3 is used to generate the neighborhood solution for the current individual to calculate the objective function value, and decide whether to accept the new solution. The temperature is continuously lowered and the above process is repeated until the iteration termination condition is reached to obtain the local optimal solution.

[0076] (3) TS enhancement: First, a taboo table is maintained for the selected individual to record the most recently visited solutions. When a new solution is generated during the SA search process, the taboo table is checked to determine whether to accept the solution or regenerate a neighborhood solution. If the new solution is accepted, the update strategy F4 is used to adaptively update the taboo table, and the taboo removal conditions are determined and applied in real time. Using TS to record visited solutions prevents cyclic search and stagnation, ensuring the diversity and effectiveness of local optimization.

[0077] (4) Iteration and fusion: Repeat the above steps, combining the global search capability of GA, the local optimization capability of SA and the memory capability of TS, and continuously iterate and optimize to the preset termination condition. In this process, the global optimal solution is recorded and updated, and the final optimal solution is output after the iteration to achieve more efficient global optimization.

[0078] In the present disclosure, the method also includes the step of adaptively adjusting the test cases generated iteratively, and the adaptive adjustment includes: normalizing the initial population fitness function and sharing the individual fitness; dividing the number of iterations of each type of heuristic algorithm, and the number of iterations is divided into early iteration, middle iteration, and late iteration; the initial group that shares the individual fitness is adaptively adjusted in turn according to each type of heuristic algorithm during the period of dividing the number of iterations.

[0079] Specifically, in this disclosure, the process of adaptively adjusting various types of heuristic algorithms during the division of the number of iterations is also described:

[0080] Adaptive adjustments during the partitioning iterations according to the genetic algorithm include:

[0081] At the beginning of iteration, the first crossover frequency and the first mutation frequency are used in combination with the individual fitness coefficient for uniform crossover, and the best is selected after random mutation;

[0082] In the middle / late stages of iteration, the second crossover frequency and the second mutation frequency are used in combination with multi-point crossover of individual fitness coefficients, and the best is selected after segmented mutation;

[0083] The first crossover frequency is higher than the second crossover frequency, and the first mutation frequency is higher than the second mutation frequency.

[0084] The adaptive adjustment during the partitioning iterations according to the simulated annealing algorithm includes:

[0085] In the early stage of iteration, the optimal solution set is slowly cooled down and the neighborhood solution is generated through the first step, and the suboptimal solution is accepted with the first probability;

[0086] In the middle / late stage of iteration, the optimal solution set is cooled down quickly and a neighborhood solution is generated through the second step length, and the suboptimal solution is accepted with the second probability;

[0087] Among them, the first step length is greater than the second step length, and the first probability is higher than the second probability.

[0088] Adaptive adjustments during the partitioning iterations according to the tabu search algorithm include:

[0089] In the early stage of iteration, the first taboo table is used and the acceptance rate is combined to adjust the diversity;

[0090] In the middle of the iteration, the second and third taboo tables are used to adjust diversity together;

[0091] In the later stage of iteration, a hierarchical taboo table is used in combination with dynamic covering to retain the optimal solution and reduce the length of the taboo table.

[0092] In the disclosed embodiment, in the above hybrid search process based on the heuristic algorithm, an adaptive adjustment method is designed to seek a better balance between solution time and solution quality. Figure 4 The figure shows a flow chart of the adaptive operator adjustment and acceptance strategy adjustment method in the embodiment of the present disclosure. Figure 4 The specific adaptive adjustment process is as follows:

[0093] Divide the iteration numbers of various types of algorithms. Assume the iteration number of GA is N. Define the 1st to N / 3 generations as the initial iteration stage, the (N / 3 + 1)th to 2N / 3 generations as the middle iteration stage, and the (2N / 3 + 1)th to N generations as the late iteration stage. For the convenience of description, in the following, the initial, middle, and late stages are still divided by the iteration number. In the examples, the boundary is still one-third. In the embodiments of the present disclosure, this division process is only an exemplary illustration. Other division processes are also within the protection scope of the present disclosure without departing from the concept of the present disclosure.

[0094] (1)In the global search stage of GA, first normalize the fitness function F1, share the individual fitness in the initial stage, and appropriately attenuate it to prevent premature convergence of individuals;

[0095] For the selection strategy, randomly divide the population into group A in the initial stage, divide it into group B (A < B) in the middle stage, retain the first part of the optimal solutions in each group, and directly enter the next iteration. In the late stage, retain the first part of the optimal solutions of the whole population and directly enter the next iteration. In the embodiments of the present disclosure, in the middle and late stages, it also includes applying SA local search and TS enhancement to the optimal solution set S in the current round;

[0096] For the crossover probability P c mutation probability P m For the selection of, for the whole population, use a higher P c and P m in the initial stage to increase the population diversity, and reduce P c and P m in the late stage to reduce the population fluctuation and facilitate the search around high-quality solutions. For individuals, individuals with high fitness use a higher P c and P m , that is, the P c and P m in the current iteration period are multiplied by a certain coefficient according to the fitness. And combined with dynamic coverage, use multi-point crossover or uniform crossover and segmented mutation. For example, use a lower P m。

[0097] (2)For the neighborhood generation strategy F3, combined with dynamic coverage, use neighborhood operations such as exchange, inversion, and insertion. Generate large-step neighborhood solutions with a higher probability in the initial stage, and generate small-step neighborhood solutions with a higher probability in the middle and late stages;

[0098] For the acceptance probability P exp , use a higher acceptance probability in the initial stage, gradually reduce the acceptance probability according to the acceptance rate and energy difference in the middle stage, and use a lower acceptance probability in the late stage;

[0099] (3) In the TS enhancement phase, for the taboo table update strategy F4, a longer taboo table is used in the early stage, and the taboo table content is increased or retained based on the acceptance rate. In the mid-term, both short-term and long-term taboo tables are used, and adjustments are made based on diversity. In the later stage, basic operations and combined operations are used in combination with dynamic coverage to hierarchical taboo tables, and the length of the taboo table is appropriately reduced.

[0100] The present disclosure also provides an interface test case automatic generation system, Figure 5 The following is a schematic diagram showing the structure of the automatic generation system of interface test cases in the embodiment of the present disclosure. Figure 5 In the invention, the system includes a construction unit and a generation unit. The construction unit is used to dynamically construct a preset rule set according to the interface parameter relationship and weight, and establish a dynamic coverage process according to the preset rule set; the generation unit is used to generate an initial population according to the dynamic coverage process, and perform global and local search on the initial population in combination with multiple heuristic algorithms to iteratively generate test cases.

[0101] Specifically, the construction unit includes a first determination module, a second determination module and a third determination module.

[0102] The first determination module is used to determine the parameter priority and preset the initial coverage strategy of the interface parameters;

[0103] The second determination module is used to determine the parameter association relationship, update the priority according to the specific combination weight and the specific combination value, and equivalently divide and replace the associated parameters;

[0104] The third determination module is used to determine the parameter constraint relationship, exclude invalid test cases, and discard, flip, and partially replace parameter combinations according to preset exclusive parameter sets.

[0105] Specifically, the system further includes an adjustment unit, which is used to perform adaptive adjustment on the iteratively generated test cases.

[0106] Specifically, the adjustment unit includes a normalization module, a division module and an adjustment module.

[0107] Normalization module, used to normalize the initial population fitness function and share individual fitness;

[0108] A division module is used to divide the number of iterations of each type of heuristic algorithm, wherein the number of iterations is divided into an early iteration, a middle iteration, and a late iteration;

[0109] The adjustment module is used to adaptively adjust the initial group of shared individual fitness in turn according to various types of heuristic algorithms during the division of the number of iterations.

[0110] In an embodiment of the present disclosure, an electronic device is further provided, the electronic device comprising at least one processor and at least one memory, the memory being data-connected to the processor, wherein:

[0111] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for automatically generating interface test cases described in the embodiment of the present disclosure.

[0112] The disclosed automatic production method, system and device of interface test cases are adaptively combined with the associated constraint relationship, priority and the like in the ATP interface parameter requirements, so as to reduce the search space of the generation process and improve the generation efficiency; and combined with the advantages of efficient global search algorithm and local search and enhancement algorithm, it can avoid falling into the local optimum while accelerating convergence, and improve the test coverage of the solution; at the same time, the disclosed method dynamically and adaptively adjusts the parameters in the generation process according to the information such as iteration cycle, dynamic coverage and internal feedback, so as to balance the solution time and solution quality. It can flexibly combine the parameter preset conditions such as parameter weight, associated relationship and constraint relationship, dynamically and adaptively adjust the case algorithm generation algorithm, reduce the number of case generation, and improve the test coverage.

[0113] Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure.

Claims

1. A method for automatically generating interface test cases, characterized in that: The method comprises: Dynamically construct a preset rule set according to the interface parameter relationship and weight, and establish a dynamic coverage process according to the preset rule set, wherein the parameter relationship includes parameter priority and parameter association relationship, and the parameter weight includes a specific combination weight in the association relationship between parameters; The process of establishing a dynamic coverage according to the preset rule set includes: Determine parameter priority and preset initial coverage strategy for interface parameters; Determine the parameter association relationship, update the priority according to the specific combination weight and specific combination value, and equally divide and replace the associated parameters; Determine parameter constraint relationships, exclude invalid test cases, and discard, flip, or partially replace parameter combinations based on preset mutually exclusive parameter sets; Dynamic coverage refers to the adaptive adjustment of the coverage strength of each parameter according to the test requirements and feedback during the algorithm execution process, including the preset of different and variable coverage strengths according to parameter priority, as well as parameter weight adjustment; among them, coverage strength is used to describe the degree to which the test case covers the combination of system input parameters, which refers to the size of the subset of all possible combinations of input parameters covered by the test case; An initial population is generated according to a dynamic coverage process, and a variety of heuristic algorithms are combined to perform global and local searches on the initial population to iteratively generate test cases.

2. The method for automatically generating interface test cases according to claim 1, characterized in that: Combining multiple heuristic algorithms to perform global and local searches on the initial population includes: Dynamic coverage global search based on genetic algorithm; Perform local search on the individual solution space based on simulated annealing algorithm; The individuals are adaptively checked and the solution space is updated based on a taboo search algorithm.

3. The method for automatically generating interface test cases according to claim 1, characterized in that: The method further comprises the step of adaptively adjusting the test cases generated iteratively.

4. The method for automatically generating interface test cases according to claim 3, characterized in that: The adaptive adjustment includes: By normalizing the initial population fitness function and sharing individual fitness; Dividing the number of iterations of each type of heuristic algorithm into the early iteration, the middle iteration, and the late iteration; The initial group of shared individual fitness is adaptively adjusted in turn during the partitioning iterations according to various types of heuristic algorithms.

5. The method for automatically generating interface test cases according to claim 4, characterized in that: Adaptive adjustments during the partitioning iterations according to the genetic algorithm include: At the beginning of iteration, the first crossover frequency and the first mutation frequency are used in combination with the individual fitness coefficient for uniform crossover, and the best is selected after random mutation; In the middle / late stages of iteration, the second crossover frequency and the second mutation frequency are used in combination with multi-point crossover of individual fitness coefficients, and the best is selected after segmented mutation; The first crossover frequency is higher than the second crossover frequency, and the first mutation frequency is higher than the second mutation frequency.

6. The method for automatically generating interface test cases according to claim 4, characterized in that: The adaptive adjustment during the partitioning iterations according to the simulated annealing algorithm includes: In the early stage of iteration, the optimal solution set is slowly cooled down and the neighborhood solution is generated through the first step, and the suboptimal solution is accepted with the first probability; In the middle / late stage of iteration, the optimal solution set is cooled down quickly and a neighborhood solution is generated through the second step length, and the suboptimal solution is accepted with the second probability; Among them, the first step length is greater than the second step length, and the first probability is higher than the second probability.

7. The method for automatically generating interface test cases according to claim 4, characterized in that: Adaptive adjustments during the partitioning iterations according to the tabu search algorithm include: In the early stage of iteration, the first taboo table is used and the acceptance rate is combined to adjust the diversity; In the middle of the iteration, the second and third taboo tables are used to adjust diversity together; In the later stage of iteration, a hierarchical taboo table is used in combination with dynamic covering to retain the optimal solution and reduce the length of the taboo table.

8. The method for automatically generating interface test cases according to any one of claims 4 to 7, characterized in that: The initial stage of iteration also includes the step of dividing the population and retaining the optimal solution of the previous part of each group before making adaptive adjustments; In the middle and later stages of iteration, before making adaptive adjustments, the step of retaining the optimal solution of the previous part of the population in combination with dynamic coverage is also included.

9. An interface test case automatic generation system, characterized in that: The system comprises a construction unit and a generation unit, A construction unit, used to dynamically construct a preset rule set according to the interface parameter relationship and weight, and establish a dynamic coverage process according to the preset rule set, wherein the parameter relationship includes parameter priority and parameter association relationship, and the parameter weight includes a specific combination weight in the association relationship between parameters; The construction unit includes a first determination module, a second determination module and a third determination module, The first determination module is used to determine the parameter priority and preset the initial coverage strategy of the interface parameters; The second determination module is used to determine the parameter association relationship, update the priority according to the specific combination weight and the specific combination value, and equivalently divide and replace the associated parameters; The third determination module is used to determine the parameter constraint relationship, exclude invalid test cases, and discard, flip, and partially replace parameter combinations according to preset mutually exclusive parameter sets; Dynamic coverage refers to the adaptive adjustment of the coverage strength of each parameter according to the test requirements and feedback during the algorithm execution process. It includes different and variable coverage strengths that can be preset according to parameter priorities, as well as parameter weight adjustment. The coverage strength is used to describe the degree to which the test case covers the combination of system input parameters, which refers to the size of the subset of all possible combinations of input parameters covered by the test case; The generation unit is used to generate an initial population according to a dynamic coverage process, and to perform global and local searches on the initial population in combination with a variety of heuristic algorithms to iteratively generate test cases.

10. The interface test case automatic generation system according to claim 9, characterized in that: The system also includes an adjustment unit, which is used to perform adaptive adjustment on the test cases generated iteratively.

11. The interface test case automatic generation system according to claim 10, characterized in that: The adjustment unit includes a normalization module, a division module and an adjustment module. Normalization module, used to normalize the initial population fitness function and share individual fitness; A division module is used to divide the number of iterations of each type of heuristic algorithm, wherein the number of iterations is divided into an early iteration, a middle iteration, and a late iteration; The adjustment module is used to adaptively adjust the initial group of shared individual fitness in turn according to various types of heuristic algorithms during the division of the number of iterations.

12. An electronic device, comprising at least one processor and at least one memory, wherein the memory is data-connected to the processor, wherein: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Method for generating test case by introducing annealing algorithm based on improved genetic algorithm

    CN118484386A