Test case priority and scale evaluation method and device in regression test scene
Through the collaborative optimization of the two-layer operator method and the capso chaotic accelerated particle swarm algorithm, the problem of difficult to determine the priority and scale of test cases in regression tests is solved, and the efficiency and coverage of regression tests are improved.
Patent Information
- Application Number
- CN202411435850.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-02-18
AI Technical Summary
In regression testing, it is difficult for the prior art to effectively determine the priority and use case set scale of test cases, resulting in inefficient testing.
A two-layer operator method is adopted to initialize the first population representing the priority of the test case and the second population representing the scale of the test case, and use the capso chaotic acceleration particle swarm algorithm to optimize the quality of the global optimal solution to form The final optimal subset of test cases.
Improve the efficiency of regression testing, reduce redundant use cases and improve test coverage and efficiency by optimizing the priority and scale of test cases.
Smart Images

Figure CN119473875A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of test case processing, and in particular to a method and device for evaluating the priority and scale of test cases in a regression testing scenario. Background Art
[0002] Before a new version of a system is released, it needs to be regression tested.
[0003] The priority of test cases in regression testing is manually defined, and some test cases are redundant in regression testing. A solution is needed to determine the priority of test cases and the size of the test case set, so as to improve the efficiency of regression testing. Summary of the invention
[0004] The embodiments of the present application provide a method and device for evaluating the priority and scale of test cases in a regression testing scenario to improve the efficiency of regression testing.
[0005] The present application embodiment adopts the following technical solutions:
[0006] In a first aspect, an embodiment of the present application provides a method for evaluating test case priority and scale in a regression test scenario, wherein the method comprises:
[0007] Initializing a first population representing the priority of test cases and a second population representing the scale of test cases in advance according to test cases in a regression test scenario to obtain a subset of test cases;
[0008] According to the test case subset, calculating the individual objective functions and constraints in the first population and the second population, and selecting the global optimal solution in each population, to obtain the first population and the second population for which the global optimal solution has been determined;
[0009] The first population and the second population for which the global optimal solution has been determined are input into a preset algorithm to optimize the quality of the global optimal solution in each population to obtain an evaluation result.
[0010] In some embodiments, the preset algorithm includes a Capso Chaos Accelerated Particle Swarm Optimization Algorithm, and the first population and the second population for which the global optimal solution has been determined are input into the preset algorithm to optimize the quality of the global optimal solution in each population, and obtain an evaluation result, including:
[0011] Using the capso chaos accelerated particle swarm algorithm to update the speed and position of individuals in the first population and the second population to form new first population and second population;
[0012] Collaborative optimization is performed based on the new first population and the new second population to obtain a global optimal solution of the new first population and the new second population.
[0013] In some embodiments, the method further comprises:
[0014] Performing chaotic neighborhood searches on the first population and the second population respectively, and updating global optimal solutions of the first population and the second population;
[0015] The iteration is repeated until the maximum number of iterations is reached, and the global optimal solution of the first population and the global optimal solution of the second population are combined to form a final optimal subset of test cases.
[0016] In some embodiments, the constraint item includes a constraint violation degree, and the step of calculating the individual objective functions and constraint items in the first population and the second population according to the test case subset, and selecting the global optimal solution in each population to obtain the first population and the second population for which the global optimal solution has been determined includes:
[0017] Calculating an objective function and a constraint violation degree for individuals in the first population and / or the second population, wherein the calculation of the objective function includes three indicators, and the calculation of the constraint violation degree is determined by a preset constraint rule;
[0018] After calculating the objective function and constraint violation degree of each population individual, sort them and select the representative individual representing the priority of the test case;
[0019] If the individual formed by combining the individuals in the first population and the second population does not satisfy the preset constraint rule, the constraint violation degree is increased by 1;
[0020] Obtaining a final indicator for comparing performance between individuals according to the second indicator, the second indicator, the third indicator, and the constraint violation degree;
[0021] The calculation of the objective function includes three indicators: the first indicator is used to measure the use case execution overhead and the degree of defect damage, the second indicator is used to measure the influencing factors of labor cost and time cost, and the third indicator is used to measure the function point test coverage rate of each module;
[0022] The preset constraint rules include at least one of the following: the order of internal test cases, the functional points recorded in the demand planning need to be covered in the new round of regression testing, and the defects that appeared in the previous round need to be re-tested in this round.
[0023] In some embodiments, the method further comprises:
[0024] Combine the individuals of the second group representing the scale of the test cases with the representative individuals of the first group representing the priority of the test cases, and calculate the objective function and constraint violation degree of each individual;
[0025] Sort the individuals in the population and select the global optimal solution of the second population representing the scale of test cases.
[0026] In some embodiments, the method further comprises:
[0027] Combined with the global optimal solution of the second population representing the scale of test cases, the representative individuals representing the priority of test cases in the first population are re-evaluated to select the global optimal solution representing the population;
[0028] Combined with the global optimal solution in the second population, the objective function and constraint function are recalculated for the representative individuals in the first population, and the individual with the best performance is taken as the global optimal solution of the first population.
[0029] In some embodiments, the step of initializing a first population representing the priority of test cases and a second population representing the scale of test cases in advance according to test cases in a regression test scenario to obtain a subset of test cases includes:
[0030] The individuals in the first population divide the operators in the first population into multiple modules according to the number of modules in this regression test, and determine the priority of the test cases under the current module;
[0031] According to the sorting results of each module, the test case priority of the overall regression test is obtained;
[0032] The individuals in the second population are divided into a plurality of modules according to the number of modules in this regression test, and the reduction degree of the test cases under the current module is determined;
[0033] After the individuals of the first population prioritize the test cases in each module, combined with the reduction factors of each module in the second population, a subset of test cases that can be finally executed is formed.
[0034] In a second aspect, an embodiment of the present application further provides a test case priority and scale evaluation device in a regression test scenario, wherein the device comprises:
[0035] An initialization module is used to initialize a first population representing the priority of test cases and a second population representing the scale of test cases in advance according to test cases in a regression test scenario, so as to obtain a subset of test cases;
[0036] A calculation module, used for calculating the individual objective functions and constraints in the first population and the second population according to the test case subset, and selecting the global optimal solution in each population to obtain the first population and the second population for which the global optimal solution has been determined;
[0037] An optimization module is used to input the first population and the second population for which the global optimal solution has been determined into a preset algorithm to optimize the quality of the global optimal solution in each population and obtain an evaluation result
[0038] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a processor; and a memory arranged to store computer executable instructions, wherein the executable instructions, when executed, cause the processor to perform the above method.
[0039] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores one or more programs. When the one or more programs are executed by an electronic device including multiple application programs, the electronic device executes the above method.
[0040] At least one of the above technical solutions adopted in the embodiment of the present application can achieve the following beneficial effects: according to the test cases in the regression test scenario, the first population representing the priority of the test cases and the second population representing the scale of the test cases are initialized in advance to obtain a subset of test cases. Further, according to the subset of test cases, the individual objective functions and constraints in the first population and the second population are calculated, and the global optimal solution in each population is selected to obtain the first population and the second population for which the global optimal solution has been determined. Finally, the first population and the second population for which the global optimal solution has been determined are input into a preset algorithm to optimize the quality of the global optimal solution in each population to obtain an evaluation result. In the above method, a double-layer operator is innovatively designed, wherein the first-layer operator represents the priority of the test case, and the second-layer operator represents the scale of the test case, and the double-layer superposition constitutes a possible optimal regression test case priority and scale subset. Through the design of the double-layer operator, the algorithm can reduce the scale of the use case while determining the priority. In addition, the above method also introduces the idea of collaborative evolution, dividing the regression test case priority and case size into two populations, and using the designed collaborative communicator to select the global optimal solution representing each population, and iterate and guide the evolution of each population. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0042] Figure 1A flowchart of a method for evaluating the priority and scale of test cases in a regression test scenario in an embodiment of the present application;
[0043] Figure 2 It is a schematic diagram of the individual specific forms of population A and population B in the initialization phase of the test case priority and scale evaluation method in the regression test scenario in the embodiment of the present application;
[0044] Figure 3 A flowchart of the calculation of individual objective functions and constraints in two populations and the selection of the global optimal solution in each sub-population in the collaborative interaction stage of the test case priority and scale evaluation method in the regression test scenario in the embodiment of the present application;
[0045] Figure 4 It is a flowchart of the test case priority and scale evaluation method in the algorithm execution stage in the regression test scenario in the embodiment of the present application;
[0046] Figure 5 This is a schematic diagram of the structure of a test case priority and scale evaluation device in a regression test scenario in an embodiment of the present application;
[0047] Figure 6 It is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0049] The inventor found that when solving the problem of prioritization and scale determination of regression test cases, the coupling of test cases between modules and within modules is not considered, which makes it impossible to be widely used in real life. In addition, the algorithm for solving the problem of prioritization and scale determination of regression test cases cannot optimize the priority of test cases and the scale of test cases at the same time. If it is a conventional capso chaos accelerated particle swarm algorithm, it is an algorithm with strong global convergence, but it is weak in local search.
[0050] In view of the above shortcomings, the co-evolutionary idea is introduced in the embodiments of the present application, and a collaborative communication method is designed so that the priority and scale of test cases can be optimized simultaneously in one generation, and finally the optimal subset of test cases in the regression test scenario can be determined. In addition, on the basis of the conventional capso algorithm, chaotic neighborhood search is added to enhance its local search capability, so that the algorithm can find a higher quality subset of regression test cases.
[0051] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0052] The present application embodiment provides a test case priority and scale evaluation method in a regression test scenario, such as Figure 1 As shown, a flow chart of a method for evaluating the priority and scale of test cases in a regression test scenario in an embodiment of the present application is provided, and the method at least includes the following steps S110 to S130:
[0053] Step S110 , pre-initialize a first population representing the priority of test cases and a second population representing the scale of test cases according to test cases in a regression test scenario to obtain a subset of test cases.
[0054] First, the regression test cases are divided into multiple modules, and then the corresponding priority sorting operators and scale reduction factors are designed within each module.
[0055] Specifically, a set of test cases with defined relevant labels can be input, and the population representing the priority of the test cases and the population representing the scale of the test cases can be initialized according to the input of the test cases, such as Figure 2 As shown, the specific forms of individuals in population A and population B.
[0056] Step S120, according to the test case subset, calculating the individual objective functions and constraints in the first population and the second population, and selecting the global optimal solution in each population, to obtain the first population and the second population for which the global optimal solution has been determined.
[0057] Based on the collaborative communication mechanism, the global optimal solution is selected for the test case priority and size population within each module of the test case, thereby guiding the next iteration. It can be understood that in the collaborative interaction stage, the calculation of individual objective functions and constraints in the two populations and the selection of the global optimal solution in each sub-population are mainly carried out. The objective function and constraint violation degree are calculated for individuals in population A. The calculation of the objective function consists of three indicators, and the calculation of the constraint violation degree is determined by a series of rules.
[0058] Step S130: input the first population and the second population for which the global optimal solution has been determined into a preset algorithm to optimize the quality of the global optimal solution in each population and obtain an evaluation result.
[0059] The preset algorithm is used to optimize the priority and scale of test cases. In addition, a chaotic neighborhood search mechanism is introduced to enhance the local search capability of the algorithm.
[0060] Specifically, the algorithm execution phase mainly inputs the two initialized populations for which the global optimal solution has been determined into the loop body of the preset algorithm, and continuously optimizes the quality of the global optimal solution of each sub-population.
[0061] Through the above method, the priority of the regression test case is determined. The method in the embodiment of the present application will prioritize the test cases within each module of the test case based on the established regression test model, thereby replacing manual definition.
[0062] Through the above method, the scale of regression test cases is reduced. While determining the priority of test cases, the method in the embodiment of the present application can also reduce the scale of test cases within each module, thereby improving the efficiency of regression testing.
[0063] In one embodiment of the present application, the preset algorithm includes a capso chaos accelerated particle swarm algorithm, and the first population and the second population for which the global optimal solution has been determined are input into the preset algorithm to optimize the quality of the global optimal solution in each population to obtain an evaluation result, including: using the capso chaos accelerated particle swarm algorithm to update the speed and position of individuals in the first population and the second population to form new first population and second population; performing collaborative optimization based on the new first population and the second population to obtain a new global optimal solution of the first population and the second population.
[0064] Entering the main loop, the capso chaos accelerated particle swarm algorithm is used to update the speed and position of the individuals in the two populations, thereby forming new populations A and B, and forming the global optimal solution of the new populations A and B.
[0065] Perform chaotic neighborhood search on population A and population B respectively, so as to update the global optimal solution of population A and population B, and repeat the iteration. Combine the global optimal solution of population A with the global optimal solution of population B, and finally form the optimal subset of the overall test case.
[0066] The iterative formula of the capso algorithm for the speed and position of individuals in the population is as follows:
[0067]
[0068] Among them, Gbestg-1 represents the global optimal solution of the previous generation.
[0069] Xi represents the position of the individual in the current population.
[0070] Vi represents the speed of individuals in the current population.
[0071] α replaces the social part in the original particle swarm algorithm, and its general value is 0.1L-0.5L.
[0072] The value of L is the maximum value of the velocity of a single particle.
[0073] c represents a chaotic sequence.
[0074] Afterwards, the steps of the collaborative communication phase are repeated to form a new global optimal solution for population A and population B.
[0075] like Figure 4 As shown, the specific steps include:
[0076] S1, input population A and population B.
[0077] S2, use the capso algorithm and the global optimal solution to update the positions of individuals in population 1 and population 2.
[0078] S3, repeat the three steps of the collaborative communication stage to select the global optimal solution of population A and population B.
[0079] S4, take the global optimal solution of population A, perform chaotic field search near it, combine it with the global optimal solution of population B, calculate the objective function and constraints, and replace it if the performance is inferior to the current global optimal solution.
[0080] S5, take the global optimal solution of population B, perform a chaotic field search near it, combine it with the global optimal solution of population A, calculate the objective function and constraints, and replace it if the performance is inferior to the current global optimal solution.
[0081] S6: Whether the maximum number of iterations has been reached.
[0082] S7, concatenate the global optimal solutions of population A and population B, and output the optimal test case set.
[0083] In one embodiment of the present application, the method also includes: performing chaotic neighborhood searches on the first population and the second population respectively, and updating the global optimal solutions of the first population and the second population; repeating the iteration until the maximum number of iterations is reached and the iteration is stopped, and the global optimal solution of the first population and the global optimal solution of the second population are combined to form a final optimal subset of test cases.
[0084] Perform chaotic neighborhood search on population A and population B respectively, so as to update the global optimal solution of population A and population B. The formula of chaotic neighborhood search is as follows:
[0085] Xc=Gbestg+SmaxradiusZk , if rand < 0.5
[0086] Xc=Gbestg-SmaxradiusZk if1>rand≥0.5
[0087] In the formula, Smax represents the maximum value of the decision variable represented by the particle, which is 1 in the embodiment of the present application.
[0088] Radius represents the search radius of the current generation.
[0089] Zk is the value of the chaotic sequence element corresponding to the position of the particle generated by the chaotic neighborhood search.
[0090] Repeat the next round of iterations until the maximum number of iterations is reached, and then stop iterating. Combine the global optimal solution of population A with the global optimal solution of population B to eventually form the optimal subset of the overall test case.
[0091] In one embodiment of the present application, the constraint items include constraint violations, and the objective functions and constraint items of individuals in the first population and the second population are calculated based on the test case subset, and the global optimal solution in each population is selected to obtain the first population and the second population for which the global optimal solution has been determined, including: calculating the objective function and constraint violation degree of individuals in the first population and / or the second population, the calculation of the objective function includes three indicators, and the calculation of the constraint violation degree is determined by a preset constraint rule; after calculating the objective function and constraint violation degree of each population individual, sorting is performed to select a representative individual representing the priority of the test case; if the first population and the second population If the individual formed by the combination of individuals in does not meet the preset constraint rules, the constraint violation degree is increased by 1; according to the second indicator, the second indicator, the third indicator and the constraint violation degree, the final indicator for comparing the performance between individuals is obtained; the three indicators included in the calculation of the objective function are the first indicator, which is used to measure the use case execution overhead and the degree of defect harm, the second indicator is used to measure the influencing factors of labor cost and time cost, and the third indicator is used to measure the functional point test coverage rate of each module; the preset constraint rules include at least one of the following: the order of internal test cases, the functional points recorded in the demand planning need to be covered in the new round of regression testing, and the defects that appeared in the previous round need to be re-tested in this round.
[0092] like Figure 4 As shown, the objective function and constraint violation degree are calculated for the individuals in population A. The objective function calculation consists of three indicators, and the constraint violation degree calculation is determined by a series of rules. After calculating the objective function and constraint violation degree of each population individual, they are sorted and representative individuals representing the test case priority are selected. The number of representative individuals is K, which is artificially set.
[0093] Indicator 1:
[0094] f1=i=1mdani*j=TFintimej-12timeTFii=1ntimej*i=1mdani
[0095] This indicator is mainly used to measure the execution overhead of use cases and the degree of defect damage, where m represents the defect number found in the last test, n represents the test case number under the module, dan represents the severity of the defect, TF represents the test index where the defect was first detected under the module, and time represents the execution time required to complete the test case.
[0096] Indicator 2:
[0097] f2=n=1Ntimen*PeonTremainn
[0098] This indicator is mainly used to measure the factors affecting labor cost and time cost. In the formula, timen represents the time required to execute the test case, N represents the time required to execute all test cases in this regression test, Peon represents the labor cost required to execute this test case, and Tremainn represents the total time to execute this and subsequent test cases in this module.
[0099] Indicator 3:
[0100] f3=1-TT1+TT2+TT3+...+TTmnm+12n
[0101] This indicator is mainly used to measure the coverage rate of function point tests for each module. Among them, n and m are the number of test cases and the number of test case function points in this module, respectively, and TT is the serial number of the first test of the function point.
[0102] Constraints:
[0103] The order of test cases within the module.
[0104] The functional points written in the demand planning need to be fully covered in the new round of regression testing.
[0105] The defects found in the previous round need to be re-tested in this round.
[0106] If the individual formed by the combination of individuals in population A and population B does not meet the above conditions, the constraint violation degree Violation will be increased by 1.
[0107] Combining indicators 1, 2, 3 and constraints, we can know that the final indicator for comparing the performance between individuals is:
[0108] Fitness=f1+f2+f3+C*Violation
[0109] Where C is a large constant, which is artificially defined.
[0110] Through the above method, the factor of considering the order of test cases is added, thus solving the problem of internal coupling of modules.
[0111] In one embodiment of the present application, the method also includes: combining individuals of a second population representing the scale of test cases with representative individuals of a first population representing the priority of test cases, and calculating the objective function and constraint violation of each individual; sorting the individuals in the population, and selecting the global optimal solution of the second population representing the scale of test cases.
[0112] In the specific implementation, the objective function and constraint violation degree are calculated for the individuals in population B in combination with the representative individuals in population A (referring to the result of the joint action of the representative individuals in population A and each individual in population B). The calculation rules are shown in indicators 1, 2, 3 and constraints. Similar to the first step, based on the objective function and constraints, a representative individual representing population B is selected, and the individual with the best performance among the representative individuals is the global optimal solution for population B.
[0113] Through the above method, a two-layer operator was designed. Each module has its own priority sorting operator and scale reduction factor, so the modules are relatively independent, solving the coupling problem between modules.
[0114] In one embodiment of the present application, the method also includes: combining the global optimal solution of the second population representing the scale of test cases, re-evaluating the representative individuals representing the priority of test cases in the first population, and selecting the global optimal solution representing the population; combining the global optimal solution in the second population, recalculating the objective function and constraint function of the representative individuals in the first population, and taking the individual with the best performance as the global optimal solution of the first population.
[0115] In specific implementation, the objective function and constraint function are recalculated for the representative individuals in population A in combination with the global optimal solution in population B, and the individual with the best performance is taken as the global optimal solution of population A.
[0116] In one embodiment of the present application, the first population representing the priority of the test cases and the second population representing the scale of the test cases are initialized in advance according to the test cases in the regression test scenario to obtain a subset of test cases, including: individuals in the first population divide the operators in the first population into multiple modules according to the number of modules in this regression test, and determine the priority of the test cases under the current module; according to the sorting result of each module, the test case priority of the overall regression test is obtained; individuals in the second population are divided into multiple modules according to the number of modules in this regression test, and the degree of reduction of the test cases under the current module is determined; after the individuals of the first population prioritize the test cases in each module, combined with the reduction factor of each module in the second population, a subset of test cases that can finally be executed is formed.
[0117] Please refer to Figure 2 , the individuals in population A divide their operators into multiple parts according to the number of modules in this regression test. For example, module 1 has 10 test cases, then the operators of module 1 can be expressed as X1, X2, X3...X10, each X represents a value of 0 or 1. By sorting these values, the priority of the test cases under the module can be known. If each module is sorted, the priority of the test cases in the overall regression test can be known.
[0118] Similarly, individuals in population B are also divided into multiple parts according to the number of modules in this regression test. Each part is represented by a reduction factor, which is also a number of 0 or 1, representing the degree of reduction of each part. After individuals in population A prioritize the test cases in each module, combined with the reduction factors of each part in population B, they form a subset of test cases that can be finally executed.
[0119] The present application embodiment also provides a test case priority and scale evaluation device 500 in a regression test scenario, such as Figure 5 As shown, a schematic diagram of the structure of a test case priority and scale evaluation device in a regression test scenario in an embodiment of the present application is provided, wherein the device 500 at least includes: an initialization module 510, a calculation module 520, and an optimization module 530, wherein:
[0120] In one embodiment of the present application, the initialization module 510 is specifically used to: initialize the first population representing the priority of the test cases and the second population representing the scale of the test cases in advance according to the test cases in the regression test scenario to obtain a subset of the test cases.
[0121] First, the regression test cases are divided into multiple modules, and then the corresponding priority sorting operators and scale reduction factors are designed within each module.
[0122] Specifically, a set of test cases with defined relevant labels can be input, and the population representing the priority of the test cases and the population representing the scale of the test cases can be initialized according to the input of the test cases, such as Figure 2 As shown, the specific forms of individuals in population A and population B.
[0123] In one embodiment of the present application, the calculation module 520 is specifically used to: calculate the individual objective functions and constraints in the first population and the second population according to the test case subset, and select the global optimal solution in each population to obtain the first population and the second population for which the global optimal solution has been determined.
[0124] Based on the collaborative communication mechanism, the global optimal solution is selected for the test case priority and size population within each module of the test case, thereby guiding the next iteration. It can be understood that in the collaborative interaction stage, the calculation of individual objective functions and constraints in the two populations and the selection of the global optimal solution in each sub-population are mainly carried out. The objective function and constraint violation degree are calculated for individuals in population A. The calculation of the objective function consists of three indicators, and the calculation of the constraint violation degree is determined by a series of rules.
[0125] In one embodiment of the present application, the optimization module 530 is specifically used to: input the first population and the second population for which the global optimal solution has been determined into a preset algorithm to optimize the quality of the global optimal solution in each population to obtain an evaluation result.
[0126] The preset algorithm is used to optimize the priority and scale of test cases. In addition, a chaotic neighborhood search mechanism is introduced to enhance the local search capability of the algorithm.
[0127] Specifically, the algorithm execution phase mainly inputs the two initialized populations for which the global optimal solution has been determined into the loop body of the preset algorithm, and continuously optimizes the quality of the global optimal solution of each sub-population.
[0128] In one embodiment of the present application, the preset algorithm includes a Capso chaos accelerated particle swarm algorithm, and the optimization module 530 is also used to
[0129] Using the capso chaos accelerated particle swarm algorithm to update the speed and position of individuals in the first population and the second population to form new first population and second population;
[0130] Collaborative optimization is performed based on the new first population and the new second population to obtain a global optimal solution of the new first population and the new second population.
[0131] In one embodiment of the present application, the optimization module 530 is also used to
[0132] Performing chaotic neighborhood searches on the first population and the second population respectively, and updating global optimal solutions of the first population and the second population;
[0133] Repeat the iteration until the maximum number of iterations is reached, and then stop the iteration, and combine the global optimal solution of the first population with the global optimal solution of the second population to form a final optimal subset of test cases.
[0134] In one embodiment of the present application, the constraint item includes a constraint violation degree, and the calculation module is further used to
[0135] Calculating an objective function and a constraint violation degree for individuals in the first population and / or the second population, wherein the calculation of the objective function includes three indicators, and the calculation of the constraint violation degree is determined by a preset constraint rule;
[0136] After calculating the objective function and constraint violation degree of each population individual, sort them and select the representative individual representing the priority of the test case;
[0137] If the individual formed by combining the individuals in the first population and the second population does not satisfy the preset constraint rule, the constraint violation degree is increased by 1;
[0138] Obtaining a final indicator for comparing performance between individuals according to the second indicator, the second indicator, the third indicator, and the constraint violation degree;
[0139] The calculation of the objective function includes three indicators: the first indicator is used to measure the use case execution overhead and the degree of defect damage, the second indicator is used to measure the influencing factors of labor cost and time cost, and the third indicator is used to measure the function point test coverage rate of each module;
[0140] The preset constraint rules include at least one of the following: the order of internal test cases, the functional points recorded in the demand planning need to be covered in the new round of regression testing, and the defects that appeared in the previous round need to be re-tested in this round.
[0141] In one embodiment of the present application, the optimization module 530 is also used to
[0142] Combine the individuals of the second group representing the scale of the test cases with the representative individuals of the first group representing the priority of the test cases, and calculate the objective function and constraint violation degree of each individual;
[0143] Sort the individuals in the population and select the global optimal solution of the second population representing the scale of test cases.
[0144] In one embodiment of the present application, the optimization module 530 is also used to
[0145] Combined with the global optimal solution of the second population representing the scale of test cases, the representative individuals representing the priority of test cases in the first population are re-evaluated to select the global optimal solution representing the population;
[0146] Combined with the global optimal solution in the second population, the objective function and constraint function are recalculated for the representative individuals in the first population, and the individual with the best performance is taken as the global optimal solution of the first population.
[0147] In one embodiment of the present application, the initialization module 510 is also used to
[0148] The individuals in the first population divide the operators in the first population into multiple modules according to the number of modules in this regression test, and determine the priority of the test cases under the current module;
[0149] According to the sorting results of each module, the test case priority of the overall regression test is obtained;
[0150] The individuals in the second population are divided into a plurality of modules according to the number of modules in this regression test, and the reduction degree of the test cases under the current module is determined;
[0151] After the individuals of the first population prioritize the test cases in each module, combined with the reduction factors of each module in the second population, a subset of test cases that can be finally executed is formed.
[0152] It can be understood that the test case priority and scale assessment device in the above-mentioned regression testing scenario can implement the various steps of the test case priority and scale assessment method in the regression testing scenario provided in the aforementioned embodiment, and the relevant explanations on the test case priority and scale assessment method in the regression testing scenario are applicable to the test case priority and scale assessment device in the regression testing scenario, which will not be repeated here.
[0153] Figure 6 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 6 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0154] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0155] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0156] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a test case priority and scale evaluation device in the regression test scenario at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0157] Initializing a first population representing the priority of test cases and a second population representing the scale of test cases in advance according to test cases in a regression test scenario to obtain a subset of test cases;
[0158] According to the test case subset, calculating the individual objective functions and constraints in the first population and the second population, and selecting the global optimal solution in each population, to obtain the first population and the second population for which the global optimal solution has been determined;
[0159] The first population and the second population for which the global optimal solution has been determined are input into a preset algorithm to optimize the quality of the global optimal solution in each population to obtain an evaluation result.
[0160] The above application Figure 1The method performed by the test case priority and scale assessment device in the regression test scenario disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0161] The electronic device may also perform Figure 1 A method for executing a test case priority and scale evaluation device in a regression test scenario, and realizing a test case priority and scale evaluation device in a regression test scenario Figure 1 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.
[0162] The present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by an electronic device including multiple application programs, enable the electronic device to execute Figure 1 The method executed by the test case priority and scale assessment device in the regression test scenario in the embodiment shown is specifically used to execute:
[0163] Initializing a first population representing the priority of test cases and a second population representing the scale of test cases in advance according to test cases in a regression test scenario to obtain a subset of test cases;
[0164] According to the test case subset, calculating the individual objective functions and constraints in the first population and the second population, and selecting the global optimal solution in each population, to obtain the first population and the second population for which the global optimal solution has been determined;
[0165] The first population and the second population for which the global optimal solution has been determined are input into a preset algorithm to optimize the quality of the global optimal solution in each population to obtain an evaluation result.
[0166] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0167] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0168] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0169] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0170] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0171] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0172] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0173] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0174] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0175] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A test case priority and scale evaluation method in a regression test scenario, wherein: The method comprises: Initializing a first population representing the priority of test cases and a second population representing the scale of test cases in advance according to test cases in a regression test scenario to obtain a subset of test cases; According to the test case subset, calculating the individual objective functions and constraints in the first population and the second population, and selecting the global optimal solution in each population, to obtain the first population and the second population for which the global optimal solution has been determined; The first population and the second population for which the global optimal solution has been determined are input into a preset algorithm to optimize the quality of the global optimal solution in each population to obtain an evaluation result.
2. The method of claim 1, wherein: The preset algorithm includes a Capso chaos accelerated particle swarm algorithm, and the first population and the second population for which the global optimal solution has been determined are input into the preset algorithm to optimize the quality of the global optimal solution in each population, and obtain an evaluation result, including: Using the capso chaos accelerated particle swarm algorithm to update the speed and position of individuals in the first population and the second population to form new first population and second population; Collaborative optimization is performed based on the new first population and the new second population to obtain a global optimal solution of the new first population and the new second population.
3. The method of claim 1, wherein: The method further comprises: Performing chaotic neighborhood searches on the first population and the second population respectively, and updating global optimal solutions of the first population and the second population; The iteration is repeated until the maximum number of iterations is reached, and the global optimal solution of the first population and the global optimal solution of the second population are combined to form a final optimal subset of test cases.
4. The method of claim 1, wherein: The constraint item includes a constraint violation degree, and the step of calculating the individual objective functions and constraint items in the first population and the second population according to the test case subset, and selecting the global optimal solution in each population to obtain the first population and the second population for which the global optimal solution has been determined includes: Calculating an objective function and a constraint violation degree for individuals in the first population and / or the second population, wherein the calculation of the objective function includes three indicators, and the calculation of the constraint violation degree is determined by a preset constraint rule; After calculating the objective function and constraint violation degree of each population individual, sort them and select the representative individual representing the priority of the test case; If the individual formed by combining the individuals in the first population and the second population does not satisfy the preset constraint rule, the constraint violation degree is increased by 1; Obtaining a final indicator for comparing performance between individuals according to the second indicator, the second indicator, the third indicator, and the constraint violation degree; The calculation of the objective function includes three indicators: the first indicator is used to measure the use case execution overhead and the degree of defect damage, the second indicator is used to measure the influencing factors of labor cost and time cost, and the third indicator is used to measure the function point test coverage rate of each module; The preset constraint rules include at least one of the following: the order of internal test cases, the functional points recorded in the demand planning need to be covered in the new round of regression testing, and the defects that appeared in the previous round need to be re-tested in this round.
5. The method of claim 4, wherein: The method further comprises: Combine the individuals of the second group representing the scale of the test cases with the representative individuals of the first group representing the priority of the test cases, and calculate the objective function and constraint violation degree of each individual; Sort the individuals in the population and select the global optimal solution of the second population representing the scale of the test cases.
6. The method of claim 5, wherein: The method further comprises: Combined with the global optimal solution of the second population representing the scale of test cases, the representative individuals representing the priority of test cases in the first population are re-evaluated to select the global optimal solution representing the population; Combined with the global optimal solution in the second population, the objective function and constraint function are recalculated for the representative individuals in the first population, and the individual with the best performance is taken as the global optimal solution of the first population.
7. The method of claim 1, wherein: The method of pre-initializing a first population representing the priority of the test cases and a second population representing the scale of the test cases according to the test cases in the regression test scenario to obtain a subset of the test cases includes: The individuals in the first population divide the operators in the first population into multiple modules according to the number of modules in this regression test, and determine the priority of the test cases under the current module; According to the sorting results of each module, the test case priority of the overall regression test is obtained; The individuals in the second population are divided into a plurality of modules according to the number of modules in this regression test, and the reduction degree of the test cases under the current module is determined; After the individuals of the first population prioritize the test cases in each module, combined with the reduction factors of each module in the second population, a subset of test cases that can be finally executed is formed.
8. A test case priority and scale evaluation device in a regression test scenario, wherein: The device comprises: An initialization module is used to initialize a first population representing the priority of test cases and a second population representing the scale of test cases in advance according to test cases in a regression test scenario, so as to obtain a subset of test cases; A calculation module, used for calculating the individual objective functions and constraints in the first population and the second population according to the test case subset, and selecting the global optimal solution in each population to obtain the first population and the second population for which the global optimal solution has been determined; The optimization module is used to input the first population and the second population for which the global optimal solution has been determined into a preset algorithm to optimize the quality of the global optimal solution in each population and obtain an evaluation result.
9. An electronic device, comprising: processor; as well as A memory arranged to store computer executable instructions, which when executed cause the processor to perform the method of any one of claims 1 to 7.
10. A computer-readable storage medium storing one or more programs, which, when executed by an electronic device including a plurality of application programs, causes the electronic device to execute any one of the methods of claims 1 to 7.