CN117149615A - Method and corresponding device for generating test case execution path - Google Patents

Method and corresponding device for generating test case execution path Download PDF

Info

Publication number
CN117149615A
CN117149615A CN202310856287.7A CN202310856287A CN117149615A CN 117149615 A CN117149615 A CN 117149615A CN 202310856287 A CN202310856287 A CN 202310856287A CN 117149615 A CN117149615 A CN 117149615A
Authority
CN
China
Prior art keywords
test case
value
determining
execution
local
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310856287.7A
Other languages
Chinese (zh)
Inventor
吴振威
丁翔峰
徐爱波
李海涛
赵明明
叶志伟
严灵毓
余军
万国
付伟夫
戴辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hubei University of Technology
Wuhan Fiberhome Technical Services Co Ltd
Original Assignee
Hubei University of Technology
Wuhan Fiberhome Technical Services Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hubei University of Technology, Wuhan Fiberhome Technical Services Co Ltd filed Critical Hubei University of Technology
Priority to CN202310856287.7A priority Critical patent/CN117149615A/en
Publication of CN117149615A publication Critical patent/CN117149615A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention relates to the technical field of software testing, and provides a method and a corresponding device for generating an execution path of a test case. According to the historical execution results corresponding to the test case sets, calculating a first weight value of each test case in the test case sets; after initializing a population, carrying out local optimization on the initial population to obtain a local result set, carrying out evolutionary computation on the local result set according to a fitness function, and iterating the process until a preset termination condition is met so as to generate an optimal test case execution path. According to the invention, the optimal test case execution path is determined by designing and considering the fitness functions of the actual output, the expected output, the code coverage rate and the execution time, so that unnecessary test cases are reduced, the problems of wasting the execution time and the resource cost are solved, the coverage rate and the coverage accuracy of the test case execution path are improved, more program errors are detected, and the regression test effect is improved.

Description

Method and corresponding device for generating test case execution path
Technical Field
The present invention relates to the field of software testing technologies, and in particular, to a method and a corresponding device for generating a test case execution path.
Background
Software testing is a process of operating or determining a certain software system using manual or automatic means, with the purpose of checking whether the software system to be tested meets a specified requirement or determining the difference between the expected operating result and the actual operating result. The execution path of the test case is a sequence of the execution order of the plurality of test cases. The selection of test case execution paths is one of important research subjects in software testing, and as the demand of a software system is continuously increased, the number of test cases required by one project is continuously increased, and the influence of different test case execution paths on the test effect is not negligible.
In the development process of the software project, regression testing is required to be carried out on the original functions after the new version is released so as to prevent the original functions from being influenced. In the prior art, the test case execution path during regression testing is usually selected manually, or the original test case execution path designed in the initial stage of program development is directly used for testing again, but the problems of excessive number of test cases, execution time waste and resource cost are caused, and the test coverage rate is low, so that the regression testing effect is poor.
In view of this, overcoming the drawbacks of the prior art is a problem to be solved in the art.
Disclosure of Invention
The invention aims to solve the technical problem of providing a method and a corresponding device for generating an execution path of a test case, wherein the method and the device are used for setting the weight of the execution path of the test case in regression test according to the historical execution result of the test case, designing a fitness function according to the related factors of the historical execution result, and generating an optimal execution path of the test case according to the fitness.
The invention adopts the following technical scheme:
in a first aspect, the present invention provides a method for generating a test case execution path, where the method includes:
acquiring a test case set, and calculating a first weight value corresponding to each test case in the test case set according to a historical execution result corresponding to the test case set;
acquiring an execution path of at least one group of test cases according to the test case set and the corresponding first weight value, and forming an initial population according to at least one execution path;
carrying out local optimization on the initial population to obtain a local result set, and carrying out evolutionary computation on the local result set according to an fitness function; carrying out local optimization and evolution calculation once each time, and carrying out local optimization and evolution calculation once again according to the result of the previous evolution calculation until a preset termination condition is met;
And after the preset termination condition is met, a candidate result set is obtained, and an execution path with highest fitness is obtained according to the candidate result set.
Further, the obtaining the test case set, according to the historical execution result corresponding to the test case set, calculating the first weight value corresponding to each test case in the test case set includes:
determining a difference between an expected output of the historical execution result and an actual output of the historical execution result as a first difference;
determining the ratio of the first difference value to the expected output as a first ratio, and determining the difference value of a first preset value and the first ratio as an output intermediate value;
carrying out logarithmic operation on the execution time of the historical execution result with the preset base number as the base to obtain a first logarithmic value, and determining the sum of the first logarithmic value and the first preset value as an execution intermediate value;
determining the sum of the program error number of the historical execution result and the first preset value as an error intermediate value;
the product of the output intermediate value and the execution intermediate value and the error intermediate value is determined as the first weight value.
Further, the initial population is subjected to local optimization to obtain a local result set, and evolution calculation is carried out on the local result set according to a fitness function; and carrying out the local optimization and the evolution calculation once each time, and carrying out the local optimization and the evolution calculation once again according to the result of the previous evolution calculation until the preset termination condition is met, wherein the steps of:
Carrying out local optimization on the initial population to obtain a local result set;
calculating fitness of all individuals of the local result set according to a fitness function, wherein one individual corresponds to one execution path;
sorting the individuals according to the corresponding fitness, selecting a preset number of individuals with the front sorting, and taking the individuals as father;
generating a plurality of filial generations according to the father generation, and constructing the new generation population according to the father generation and the filial generation until the population size of the new generation population is the same as the population size of the initial population, so as to generate the new generation population;
and after each time of local optimization and evolution calculation, taking the new generation population as the initial population, and carrying out the next local optimization and the next evolution calculation until a preset termination condition is met.
Further, the performing local optimization on the initial population to obtain a local result set includes:
randomly acquiring at least one individual according to the initial population, and randomly generating the current position and the current speed of the individual according to a preset rule;
In each iteration, determining a difference value between a historical optimal position and the current position as a second difference value, determining a difference value between a global optimal position and the current position as a third difference value, determining a product of a current speed of the individual in a previous iteration and a preset inertia weight as a first inertia value, determining a product of a first random number and a first acceleration coefficient and the second difference value as an individual cognition value, determining a product of a second random number and a second acceleration coefficient and the third difference value as a social cognition value, determining a sum of the first inertia value and the individual cognition value and the social cognition value as a current speed of a next iteration, and determining a sum of the current position and the current speed of the next iteration as a current position of the next iteration;
in each iteration, calculating the local fitness of all the individuals according to the current position, obtaining a historical optimal position of the current iteration and a global optimal position of the current iteration according to a local optimization rule and the local fitness, and determining the current speed of the next iteration and the current position of the next iteration according to the historical optimal position and the global optimal position until a local termination condition is met;
And after the local termination condition is met, obtaining the local result set.
Further, the calculating fitness of all the individuals of the local result set according to the fitness function, wherein one individual corresponds to one execution path includes:
calculating a first accuracy value of the test case in each local result set according to a preset accuracy rule and the historical execution result; determining the sum of the first accuracy values of the test cases corresponding to the individuals as a second accuracy value of the individuals, and determining the product of the second accuracy value and the accuracy weight as a third accuracy value;
determining the ratio of the total number of functional modules covered by one individual to the total number of functional modules covered by all test cases in the local result set as a second ratio, and determining the product of the second ratio and coverage rate weight as a coverage rate value;
determining the ratio of the sum of the execution time of all the test cases in the individual to the sum of the execution time of all the test cases in the local result set as a third ratio, and determining the product of the third ratio and the efficiency weight as an efficiency value;
and determining the sum of the third accuracy value, the coverage value and the efficiency value as the fitness of the individual.
Further, the ranking of the individuals according to the corresponding fitness, selecting a preset number of individuals with the top ranking, and taking the individuals as parents includes:
determining the sum of all the fitness degrees as the total fitness degree;
determining a ratio of fitness of each of the individuals to the total fitness as a selection probability for each of the individuals;
and sorting the selection probabilities, selecting a preset number of individuals with the top sorting, and taking the individuals as parents.
Further, the generating a plurality of offspring according to the parent, and constructing the new generation population according to the parent and the offspring until the population size of the new generation population is the same as the population size of the initial population, and the generating the new generation population includes:
randomly acquiring two father parents, and performing cross operation to obtain two first offspring;
performing mutation operation on the two first filial generations to obtain two second filial generations;
the two first offspring and the two second offspring are used as part of the new generation population;
and in each iteration, performing at least one cross operation and at least one mutation operation until the population size of the new generation population is the same as the population size of the initial population, and generating the new generation population.
Further, the step of randomly obtaining the two parents, and performing a cross operation to obtain two first offspring includes:
randomly acquiring two father parents which are respectively used as a first father parent and a second father parent;
sequentially acquiring intervals with the length of the first parent as first intervals; sequentially acquiring intervals with the length of the second parent as second intervals; wherein the sums are both a random value that is less than the length of the first parent and a random value of the length of the second parent;
the data of the second interval is replaced by the data of the first interval, the data of other intervals of the second parent are kept unchanged, and the first child is obtained according to the replaced data and the original data;
and replacing the data of the first interval with the data of the second interval, wherein the data of other intervals of the first parent are kept unchanged, and the other first child is obtained according to the replaced data and the original data.
Further, the performing mutation operation on the two first filial generations to obtain two second filial generations includes:
sequentially acquiring one test case with the position in the first offspring as a first test case; wherein, and is a random value less than the length of the first child;
Sequentially acquiring one test case with the position in the first offspring as a second test case; wherein, and is a random value less than the length of the first child;
and in the first offspring, exchanging the position of the first test case with the position of the second test case to obtain the second offspring.
In a second aspect, the present invention further provides a device for generating an execution path of a test case, where the device includes at least one processor and a memory, the at least one processor and the memory are connected through a data bus, and the memory stores an instruction that can be executed by the at least one processor, where the instruction is used to complete the method for generating the execution path of the test case according to the first aspect after being executed by the processor.
In a third aspect, the present invention also provides a non-volatile computer storage medium storing computer executable instructions that are executed by one or more processors to perform the method for generating the test case execution path according to the first aspect.
Unlike the prior art, the invention has at least the following beneficial effects:
According to the invention, a first weight value is set according to the historical execution result of the test case, an initial population is generated according to the first weight value, an optimal test case execution path is determined by designing and considering the fitness function of actual output, expected output, code coverage rate and execution time by utilizing a genetic programming algorithm, unnecessary test cases are reduced, the problem of wasting execution time and resource cost is solved, the coverage rate and coverage accuracy of the test case execution path are improved, more program errors are detected, and the regression test effect is improved.
Drawings
In order to more clearly illustrate the technical solution of the embodiments of the present invention, the drawings that are required to be used in the embodiments of the present invention will be briefly described below. It is evident that the drawings described below are only some embodiments of the present invention and that other drawings may be obtained from these drawings without inventive effort for a person of ordinary skill in the art.
FIG. 1 is a general flow chart of a generic software test;
FIG. 2 is a general flow chart of a method for generating a test case execution path according to an embodiment of the present invention;
FIG. 3 is a schematic flow chart of step 10 according to an embodiment of the present invention;
FIG. 4 is a schematic flow chart of step 30 according to an embodiment of the present invention;
FIG. 5 is a schematic flow chart of step 301 according to an embodiment of the present invention;
FIG. 6 is a schematic flow chart of step 302 according to an embodiment of the present invention;
FIG. 7 is a schematic flow chart of step 303 of the embodiment of the present invention;
FIG. 8 is a schematic flow chart of step 304 according to an embodiment of the present invention;
FIG. 9 is a schematic diagram showing a specific flow of step 3041 according to an embodiment of the present invention;
FIG. 10 is a schematic flow chart of step 3042 according to the embodiment of the invention;
FIG. 11 is a flowchart illustrating a method for generating a test case execution path according to an embodiment of the present invention;
fig. 12 is a schematic diagram of an architecture of a device for generating an execution path of a test case according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
In the description of the present invention, the terms "inner", "outer", "longitudinal", "transverse", "upper", "lower", "top", "bottom", etc. refer to an orientation or positional relationship based on that shown in the drawings, merely for convenience of describing the present invention and do not require that the present invention must be constructed and operated in a specific orientation, and thus should not be construed as limiting the present invention.
The terms "first," "second," and the like herein are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first", "a second", etc. may explicitly or implicitly include one or more such feature. In the description of the present application, unless otherwise indicated, the meaning of "a plurality" is two or more.
In addition, the technical features of the embodiments of the present application described below may be combined with each other as long as they do not collide with each other.
Example 1:
regression testing refers to testing the software system again after modifying the old code of the software system to confirm that the modification did not introduce new errors or caused other code to produce errors. As shown in FIG. 1, the regression test is used as a component of the software life cycle, and takes a great deal of work weight in the whole software test process, and multiple regression tests are carried out at each stage of software development. Before regression testing, the test case execution path of the originally designed test case set needs to be planned, so that the effect of regression testing is ensured.
The original test case execution path designed in the initial stage of program development is directly used for testing again, and unnecessary test cases cannot be eliminated according to specific regression test scenes. For example, in functional test or some interface tests, the pre-conditions of test cases of part of scenes are the same, when the test cases are put together for testing, the test execution time can be obviously saved, and the test efficiency is improved. The number of test cases is too large, so that execution time and resource cost are wasted, and since the test scenario of the regression test is to modify old codes, which may involve the addition of functional modules of the software system and/or iteration of versions of the software system, resulting in a change in the logic sequence of the old codes and/or the interaction sequence between the functional modules, using the original test case execution path may result in poor test coverage, so that the regression test is less effective.
The embodiment of the invention can exclude unnecessary test cases from a large number of test cases in the original test case set, so as to solve the problems of execution time waste and resource cost caused by excessive number of test cases and avoid the problem of poor regression test effect caused by low test coverage rate. Specifically, as shown in fig. 2, an embodiment of the present invention provides a method for generating an execution path of a test case, where the method includes:
Step 10: acquiring a test case set, and calculating a first weight value corresponding to each test case in the test case set according to a historical execution result corresponding to the test case set.
According to the method for generating the test case execution path, according to the historical execution result of the test case, a corresponding first weight value is set for each test case in the test case set and used for representing the priority of the test case. The test case set is designed during software project development. When the execution path of the test by using the test case is calculated for the second time, the historical execution result of the first test is obtained; when the test case has two or more historical execution results, a person skilled in the art designates a certain historical execution result according to the specific regression test scene requirement to calculate the corresponding first weight value.
Step 20: and acquiring an execution path of at least one group of test cases according to the test case set and the corresponding first weight value, and forming an initial population according to at least one execution path.
The generation method of the test case execution path in the embodiment of the invention uses a genetic programming algorithm to calculate the optimal execution path of the test case. Firstly, the first weight value (i.e. priority) of each test case calculated in step 10 is ordered, and since different test cases belong to different functional modules and there are test cases for testing the whole system, a person of ordinary skill in the art specifies, according to a specific regression test scenario, the functional modules and/or systems that must be covered by the execution paths of the test cases, and the number intervals of the test cases of the functional modules and/or the number intervals of the test cases of the system. Selecting at least one test case with the highest first weight value for the functional module; selecting at least one test case with the highest first weight value for the system; initializing an execution path of at least one set of test cases.
Step 30: carrying out local optimization on the initial population to obtain a local result set, and carrying out evolutionary computation on the local result set according to an fitness function; and carrying out the local optimization and the evolution calculation once each time, and carrying out the local optimization and the evolution calculation once again according to the result of the previous evolution calculation until the preset termination condition is met.
Wherein, the preset termination condition is specified by the person skilled in the art according to the actual test scene. In an alternative embodiment, a manually specified maximum number of iterations is used as a preset termination condition; or using the fitness evaluation function, and stopping iteration when the change of the fitness function is lower than a manually specified preset value.
Each time a new population is generated, initializing a globally optimal solution: the fitness of the first individual is taken as the initial global optimal solution. And for each individual, comparing the fitness with the fitness of the current global optimal solution, if the fitness is better, updating the global optimal solution into the individual, and repeating the updating step until all the individuals are traversed, and determining the global optimal solution.
According to the method for generating the test case execution path, disclosed by the embodiment of the invention, a particle swarm algorithm is nested in a genetic programming algorithm, the population is locally optimized, a local result set is obtained, and three genetic operators of selection, intersection and variation are used for evolving the local result set. Because the genetic programming algorithm is easy to fall into a local optimal solution and the particle swarm algorithm is nested, the initial population is finely searched and optimized, the quality and diversity of the population are improved, the efficiency and the convergence speed are improved while the optimization quality is ensured, and the practical degree of the test case execution path in the application scene of the large-scale test case set is improved, so that the test case execution path generation method is more suitable for large-scale software test projects.
Step 40: and after the preset termination condition is met, a candidate result set is obtained, and an execution path with highest fitness is obtained according to the candidate result set. And selecting the test case execution path with the highest fitness in the candidate result set as an optimal solution to generate the test case execution path aiming at the regression test.
In order to better explain the method for generating the test case execution path of the present invention, step 10 of the method for generating the test case execution path of the embodiment of the present invention is further refined, specifically, as shown in fig. 3, the step 10 includes:
step 101: a difference between the expected output of the historical execution result and the actual output of the historical execution result is determined as a first difference.
Step 102: and determining the ratio of the first difference value to the expected output as a first ratio, and determining the difference value of a first preset value and the first ratio as an output intermediate value.
Step 103: carrying out logarithmic operation on the execution time of the historical execution result with the preset base number as the base to obtain a first logarithmic value, and determining the sum of the first logarithmic value and the first preset value as an execution intermediate value;
step 104: and determining the sum of the program error number of the historical execution result and the first preset value as an error intermediate value.
Step 105: the product of the output intermediate value and the execution intermediate value and the error intermediate value is determined as the first weight value.
In the data preprocessing method, the data are all scaled to the interval so as to adjust the importance degree of the output intermediate value, the execution intermediate value and the error intermediate value to the first weight value to the same interval, and the reduction of the value is convenient for a computer to calculate and store.
Wherein the preset base number is specified by a person of ordinary skill in the art according to a specific regression testing scene, and in an alternative embodiment, the base number of the default logarithmic function is 10 by using a logarithmic function method carried by a brother computer programming language.
The first weight value calculation formula of the generation method of the test case execution path in the embodiment of the invention is as follows:
Weight§=(1-|E-A|/E)×(1+logT)×(1+N bug )
wherein Weight represents Weight, E represents expected output of a test case history execution result, A represents actual output of a test case history execution result, T represents execution time of a test case history execution result, N bug The number of program errors (bugs) representing the result of the historical execution of a test case.
The number of execution time is often smaller than the first ratio and the number of program errors, or the corresponding number is larger when the number of the unit order is smaller, so that the number is subjected to logarithmic processing, the importance degree of the number to the first weight value is adjusted under the condition that the data property and the correlation are not changed, and the complexity of multiplication calculation is higher than that of addition calculation in a bottom processing program of a computer, the logarithmic processing can convert the multiplication calculation into the addition calculation so as to facilitate the improvement of the calculation efficiency, and finally, the reduction of the number is convenient for the calculation and storage of the computer.
For the test case set, the input parameters of the test case are unified into a dictionary form in an alternative embodiment through data formatting processing. The processed data can be more suitable for the requirements of the generation method of the test case execution path in the embodiment of the invention, and the stability and the effectiveness of the algorithm are ensured.
In alternative embodiments, data preprocessing of the test case set may also include data normalization, data cleansing, and/or data conversion. Wherein data normalization, data cleansing and data conversion are used to format the data of the test case set. The following is an example of data normalization, data cleaning and data conversion for a test case set, which are provided in the embodiment of the present invention, specifically:
Raw data:
test case 1 input (2, 3), expected output 5, actual output 4, execution time 1s, find 2 bugs.
Test case 2 input (-1, 4), expected output 3, actual output 2, execution time 2s, found 1 bug.
Test case 3 input (5, 2), expected output 7, actual output 7, execution time 3s, found 3 bugs.
Data normalization:
the types of input parameters are unified into dictionary form.
For test case 1 and test case 3, the input parameters are dictionary type, and no additional processing is required.
For test case 2, the input parameters (2, 3) are converted into dictionary form.
Data cleaning: and cleaning or processing the abnormal data or the error data. In this example, the data is clean, with no obvious anomalies or errors.
Data conversion:
according to the provided actual output and execution time, calculating a first weight value of each test case in the test case set, as shown in the following table:
after the test case set is subjected to data preprocessing and the first weight value is calculated, step 20 is executed, and an initial population is constructed according to the test case set and the corresponding first weight value, so that an optimal test case execution path is searched by using a genetic algorithm.
In order to better explain the method for generating the test case execution path of the present invention, step 30 of the method for generating the test case execution path of the embodiment of the present invention is further refined, specifically, as shown in fig. 4, the step 30 includes:
step 301: and carrying out local optimization on the initial population to obtain a local result set.
Step 302: and calculating fitness of all individuals of the local result set according to a fitness function, wherein one individual corresponds to one execution path.
Step 303: and sequencing the individuals according to the corresponding fitness, selecting a preset number of individuals with the front sequencing, and taking the individuals as father.
Step 304: generating a plurality of filial generations according to the father generation, and constructing the new generation population according to the father generation and the filial generation until the population size of the new generation population is the same as the population size of the initial population, so as to generate the new generation population.
Step 305: and after each time of local optimization and evolution calculation, taking the new generation population as the initial population, and carrying out the next local optimization and the next evolution calculation until a preset termination condition is met.
Wherein the preset number is specified by one of ordinary skill in the art according to a specific regression testing scenario.
According to the method for generating the test case execution path, at least one iteration is performed on local optimization and evolutionary computation of the population, so that the optimal execution path is generated. In order to better explain the method for generating the test case execution path of the present invention, step 301 of the method for generating the test case execution path of the embodiment of the present invention is further refined, specifically, as shown in fig. 5, the step 301 includes:
step 3011: and randomly acquiring at least one individual according to the initial population, and randomly generating the current position and the current speed of the individual according to a preset rule.
Step 3012: in each iteration, determining a difference value between a historical optimal position and the current position as a second difference value, determining a difference value between a global optimal position and the current position as a third difference value, determining a product of a current speed of the individual in a previous iteration and a preset inertia weight as a first inertia value, determining a product of a first random number and a first acceleration coefficient and the second difference value as an individual cognition value, determining a product of a second random number and a second acceleration coefficient and the third difference value as a social cognition value, determining a sum of the first inertia value and the individual cognition value and the social cognition value as a current speed of a next iteration, and determining a sum of the current position and the current speed of the next iteration as a current position of the next iteration.
Step 3013: in each iteration, calculating the local fitness of all the individuals according to the current position, obtaining a historical optimal position of the current iteration and a global optimal position of the current iteration according to a local optimization rule and the local fitness, and determining the current speed of the next iteration and the current position of the next iteration according to the historical optimal position and the global optimal position until a local termination condition is met.
Step 3014: and after the local termination condition is met, obtaining the local result set.
The preset rules are automatically specified by a person of ordinary skill in the art according to specific regression testing scenes under the condition that the current position and the current speed are ensured to be within the feasible solution range; the preset inertia weight, the first acceleration coefficient and the second acceleration coefficient are automatically specified by a person of ordinary skill in the art according to a specific regression testing scene; the first random number and the second random number are both random numbers between [0,1 ]; the local fitness function and the local optimization rule are self-specified by a person of ordinary skill in the art according to a specific regression testing scenario; in an alternative embodiment, according to the local fitness of each particle, a domain search algorithm is used, and according to the local fitness of the particle, the historical optimal position of the particle in the iteration and the global optimal position of the particle in the iteration are obtained; the local termination condition is specified by one of ordinary skill in the art, based on the specific regression testing scenario, and in an alternative embodiment, the maximum number of iterations of the local optimization is specified as the termination condition.
According to the method for generating the test case execution path, a generation of new population is generated each time, and the particle swarm algorithm is used for finding the optimal solution in the generation of population, so that the situation that the genetic programming algorithm converges too fast to cause the sinking of the local optimal solution is prevented.
Wherein, a particle is a test case execution path, and the particle represents a candidate solution of an optimization problem, and in the embodiment of the invention, the particle specifically refers to the test case execution path; the position of the particle represents the position of the candidate solution in the problem space, and the position with highest local fitness of the particle in the problem space is finally determined; the velocity represents the velocity at which the candidate solution moves in the problem space.
And randomly generating a certain number of particles in the search space, and randomly generating an initial current position and a current speed under the condition that the current position and the current speed of the particles are within a feasible solution range. And calculating the local fitness of each particle according to the historical execution result of the test case execution path and the local fitness function so as to evaluate the goodness of the current position of the particle in the problem space. And updating the speed and the position of the particles according to the historical optimal position, the global optimal position and the current position of the particles. One specific update formula is as follows:
The velocity formula:
v i t+1 =wv i t +c 1 r 1 (pbest i -x i t )+c 2 r 2 (gbest-x i t )
and (3) a position formula:
x i t+1 =x i t +v i t+1
wherein v represents the current speed, x represents the current position, v i t+1 Represents the velocity of the ith particle at time t+1, w represents the inertial weight, c 1 Representing a first acceleration coefficient, c 2 Representing a second acceleration coefficient, r 1 And r 2 Is [0,1 ]]Random number, pbest between i Represents the historical optimal position of the ith particle, gbest represents the global optimal position of the ith particle, x i t The position of the ith particle at time t is indicated, t representing the number of current iterations.
Wherein the formula represents the manner in which the particles move in the search space, wherein the inertial weights are used to control the inertia of the particles, the acceleration coefficients are used to control the acceleration of the particles, and the historical optimal position and the global optimal position are used to guide the particles to move in a better direction.
Premature convergence of the genetic programming algorithm means that super individuals appear in the population early in the genetic algorithm, and the fitness of the individuals greatly exceeds the average individual fitness of the current population. Therefore, the individuals quickly occupy absolute proportion in the population, the diversity of the population is rapidly reduced, and the evolution capability of the population is basically lost, so that the algorithm is converged to the local optimal solution earlier. The essential feature of premature convergence is that the individual individuals in the population are very similar and the diversity of the population decreases dramatically. Since step 10 of the embodiment of the present invention calculates the first weight value according to the expected output and the actual output of the historical execution result of the test case, the execution time and the number of program errors, step 20 of the embodiment of the present invention sets the priority for the test case according to the magnitude of the first weight value, initializes the population according to the priority, step 30 of the embodiment of the present invention performs the selection operation on the individual according to the fitness, and calculates the fitness according to the expected output and the actual output of the historical execution result, the code coverage rate and the execution time, as described later, and the factor of evaluating the priority coincides with the factor of evaluating the fitness in two aspects, so that in the initial population, the fitness of a certain individual easily exceeds the average individual fitness of the population, that is, the super individual, resulting in that in the regression test scene of the embodiment of the present invention, the genetic programming algorithm falls into the locally optimal solution.
In order to solve the problem, the embodiment of the invention uses the searching capability of the particle swarm algorithm to reserve more different solutions in the population so as to avoid the situation that the genetic programming algorithm converges too fast to cause the sinking of local optimal solutions; the particle swarm algorithm has stronger local searching capability, and a local optimal solution is found through rapid convergence in a relatively short time, so that fine searching and optimization are performed around each individual in the genetic programming algorithm, the quality and diversity of the population are improved in a limited iteration number, and the efficiency and convergence speed of the algorithm are improved; when the search space of the problem is larger or the complex parameter space is provided, the particle swarm algorithm can be better explored and optimized, and the effect is more obvious on the use scene with more test cases.
In order to better illustrate the method for generating the test case execution path of the present invention, step 302 of the method for generating the test case execution path of the embodiment of the present invention is further refined, specifically, as shown in fig. 6, the step 302 includes:
step 3021: calculating a first accuracy value of the test case in each local result set according to a preset accuracy rule and the historical execution result; and determining the sum of the first accuracy values of the test cases corresponding to the individuals as a second accuracy value of the individuals, and determining the product of the second accuracy value and the accuracy weight as a third accuracy value.
According to the selected historical execution result corresponding to the test case in each local result set, calculating a first accuracy value of actual output and expected output, wherein a preset accuracy rule is specified by a person of ordinary skill in the art according to a specific regression test scene, in an alternative embodiment, the ratio of the actual output to the expected output is taken as a calculation error rate, and the calculation error rate is taken as the first accuracy value.
Step 3022: and determining the ratio of the total number of the functional modules covered by the individual to the total number of the functional modules covered by all the test cases in the local result set as a second ratio, and determining the product of the second ratio and the coverage rate weight as a coverage rate value.
In the process of generating the test case execution path of the primary regression test, the total number of the functional modules covered by each test case is unchanged, and the total number of the functional modules covered by all test cases in the test case execution path is the total number of the functional modules covered by the test case execution path.
Step 3023: and determining the ratio of the sum of the execution time of all the test cases in the individual to the sum of the execution time of all the test cases in the local result set as a third ratio, and determining the product of the third ratio and the efficiency weight as an efficiency value.
Step 3024: and determining the sum of the third accuracy value, the coverage value and the efficiency value as the fitness of the individual.
The fitness is a measure of the quality of the execution path of the test case, and the fitness function is a function for determining the execution effect of the genetic programming algorithm based on the evaluation index, which converts the excellent characteristics of each individual in the population into numerical values so as to select, cross and mutate the individual according to the numerical values, and the definition of the fitness function determines how to evaluate the performance of each individual in the optimization process. In the problem of optimizing the execution path of the test case of the regression test, the embodiment of the invention establishes the association by taking the code coverage rate, the execution time, the expected output and the actual output of the execution path of the test case as evaluation indexes, realizes multi-objective optimization and improves the test effectiveness of the execution path of the optimal test case. Mapping the execution path of the test case to the numerical space of the fitness function, and calculating the fitness value by distributing corresponding weight values to each test case, establishing the mapping relation between the execution path of the test case and the fitness. The regression test involves different processes of software test, such as unit test and system test, and corresponding test requirements are different.
Specifically, the fitness function of the embodiment of the invention considers three factors of accuracy, code coverage rate and test efficiency. In an alternative embodiment, statement coverage and/or branch coverage of the execution path of the test case is calculated in conjunction with a specific code coverage tool.
The test case execution path (i.e., individual) in the set of partial results is p= (P) 1 ,P 2 ……P n ) The test case set is t= { T 1 ,t 2 ……t m Test case t i The covered functional module set is M i Test case t i The execution time isOne specific formula of the fitness function is:
fitness§=w 1 ×Σ_{t i ∈P}A i +w 2 ×|∪_{t i ∈P}M i |/|∪_{t i ∈T}M i |+w 3 ×Σ_{t i ∈P}t_exec i /Σ_{t i ∈T}t_exec i
wherein i is the corresponding subscript, w 1 For accuracy weight, w 2 For coverage weight, w 3 As the efficiency weight, A i Representing test case t i Representing the sum of the first accuracy values of all test cases in the test case execution path P, |U_ { t- i ∈P}M i The I represents the total number of all functional modules covered by the test case execution path P, and I U_ { t i ∈T}M i I represents the total number of all functional modules covered by all test cases in the local result set,representing the sum of the execution times of the test case execution paths P,/-> Representing the sum of the execution time of all test cases in the local result set.
In order to better illustrate the fitness function of the generating method of the test case execution path, the embodiment of the invention provides a specific implementation pseudo code (Python format, wherein Python is a computer programming language) for defining the fitness function, which is specifically as follows:
def calculate_fitness(individual,actual_outputs,expected_outputs,code_coverage,execution_time):
··fitness=weight1*calculate_accuracy(actual_outputs,expected_outputs)+\
······weight2*calculate_coverage(code_coverage)+\
······weight3*calculate_efficiency(execution_time)
··return fitness
In order to better explain the method for generating the test case execution path of the present invention, step 303 of the method for generating the test case execution path of the embodiment of the present invention is further refined, specifically, as shown in fig. 7, the step 303 includes:
step 3031: the sum of all the fitness measures is determined as the total fitness measure.
Step 3032: the ratio of fitness of each of the individuals to the total fitness is determined as a probability of selection for each of the individuals.
Step 3033: and sorting the selection probabilities, selecting a preset number of individuals with the top sorting, and taking the individuals as parents.
Wherein the preset number is specified by one of ordinary skill in the art according to a specific regression testing scenario.
And selecting an excellent individual as a parent according to a certain strategy according to the value of the fitness function. In alternative embodiments, proportional selection or tournament selection is used as the selection strategy.
In order to better illustrate the selection operation of the generation method of the test case execution path, the embodiment of the invention provides a specific implementation pseudo code (Python format) for defining the selection operation, which is specifically as follows:
def selection(population):
··fitness_values=[fitness(i)for i in population]
··total_fitness=sum(fitness_values)
··probabilities=[f/total_fitness for f in fitness_values]
··population=list(zip(population,probabilities))
··population=sorted(population,key=lambda x:x[1],reverse=True)
··selected=[i[0]for i in population[:20]]
··return selected
in order to better illustrate the method for generating the test case execution path of the present invention, step 304 of the method for generating the test case execution path of the embodiment of the present invention is further refined, specifically, as shown in fig. 8, the step 304 includes:
Step 3041: and randomly acquiring the two parents, and performing cross operation to obtain two first offspring.
Step 3042: and performing mutation operation on the two first filial generations to obtain two second filial generations.
Step 3043: the two first offspring and the two second offspring are used as part of the new generation population.
Step 3044: and in each iteration, performing at least one cross operation and at least one mutation operation until the population size of the new generation population is the same as the population size of the initial population, and generating the new generation population. Wherein the new generation population generated by each iteration comprises two parents, two first offspring and two second offspring. Wherein the population is of a size that is the number of individuals.
In order to better explain the method for generating the test case execution path of the present invention, step 3041 of the method for generating the test case execution path of the embodiment of the present invention is further refined, specifically, as shown in fig. 9, the step 3041 includes:
step 30411: and randomly acquiring two parents, wherein the two parents are respectively used as a first parent and a second parent.
Step 30212: sequentially obtaining intervals with the lengths of [ a, b ] in the first parent as a first interval; sequentially obtaining intervals with the lengths of [ a, b ] in the second parent as second intervals; wherein 0< a < b, a and b are both random values that are smaller than the length of the first parent and random values of the length of the second parent at the same time.
Step 3043: and replacing the data of the second interval with the data of the first interval, wherein the data of other intervals of the second parent are kept unchanged, and obtaining a first child according to the replaced data and the original data.
Step 30414: and replacing the data of the first interval with the data of the second interval, wherein the data of other intervals of the first parent are kept unchanged, and the other first child is obtained according to the replaced data and the original data.
Embodiments of the present invention treat one individual as a chromosome and create a new individual by exchanging single-point genes in the chromosomes of both individuals. In an alternative embodiment, multi-point crossing or uniform crossing is used, so that the complexity of crossing operation is improved, a plurality of test case execution paths are obtained more quickly, the diversity of the test case execution paths in the population during each iteration is improved, and the convergence speed of a genetic algorithm is improved.
In order to better illustrate the cross operation of the generating method of the test case execution path, the embodiment of the invention provides a specific implementation pseudo code (Python format) for defining the cross operation, which is specifically as follows:
def crossover(individual1,individual2):
··n=len(individual1)
··idx1=random.randint(0,n-1)
··idx2=random.randint(0,n-1)
··if idx1>idx2:
····idx1,idx2=idx2,idx1
··child1=individual1[:idx1]+individual2[idx1:idx2]+individual1[idx2:]
··child2=individual2[:idx1]+individual1[idx1:idx2]+individual2[idx2:]
··return child1,child2
in order to better explain the method for generating the test case execution path of the present invention, step 3042 of the method for generating the test case execution path of the embodiment of the present invention is further refined, specifically, as shown in fig. 10, the step 3042 includes:
Step 30421: sequentially obtaining one test case with the position c in the first offspring as a first test case; wherein c >0 and c is a random value less than the length of the first child;
step 30422: sequentially acquiring one test case with the position d in the first offspring as a second test case; wherein d >0 and d is a random value less than the length of the first child;
step 30423: and in the first offspring, exchanging the position of the first test case with the position of the second test case to obtain the second offspring.
According to the embodiment of the invention, an individual is regarded as a chromosome, and a new change is introduced by randomly changing a gene value of the chromosome, so that the diversity of the population is improved.
In order to better illustrate the mutation operation of the generating method of the test case execution path, the embodiment of the invention provides a specific implementation pseudo code (Python format) for defining the mutation operation, which is specifically as follows:
def mutation(individual):
··idx1=random.randint(0,len(individual)-1)
··idx2=random.randint(0,len(individual)-1)
··individual[idx1],individual[idx2]=individual[idx2],individual[idx1]
··return individual
the following is a specific example of an evolutionary computation provided in the embodiment of the present invention, which is specifically as follows:
after the selection operation, two individuals were obtained: "4-2-5-3-1" and "5-2-4-3-1". After the crossover operation, a new individual is obtained: "4-2-4-3-1" and "5-2-5-3-1" (assuming that single-point crossover is performed, the crossover point is the third gene). After the mutation procedure, a new individual is obtained: "4-2-4-2-1" and "5-2-5-2-1" (assuming random variation of the fourth gene).
In order to better illustrate the training method of the present invention, step 40 of the training method of the screening model of the embodiment of the present invention is further described below. After the preset termination condition is met, a candidate result set is obtained, individuals in the candidate result set are ranked according to the corresponding fitness, and the individual with the highest fitness (namely the test case execution path) is obtained. In an alternative embodiment, a replenishment operation is used to ensure that a preset replenishment number of individuals with the highest fitness in each iteration are retained to the candidate result set. Wherein, the preset supplement number is specified by the person skilled in the art according to the specific test scene of the regression test.
In order to better illustrate the complementary operation of the generating method of the test case execution path, the embodiment of the invention provides a specific implementation pseudo code (Python format) for defining the complementary operation, which is specifically as follows:
def elitism(population,num_elites):
··population=sorted(population,key=lambda i:fitness(i),reverse=True)
··elites=population[:num_elites]
··return elites
it should be noted that in the execution path of a test case, a test case may repeatedly appear, where the code coverage of the test case is the same in each test. Because the architecture of modern software is complex, in the actual software test, when the packaged functional modules and methods of all levels are called, a certain randomness exists in the execution of codes, different results can appear when the same piece of codes are executed by using the same data, the software test is just to ensure the execution result to the greatest extent in a software processable section based on the situation, and when the test fails, the original codes are modified and the version iterated according to the test result.
The method and the device have the advantages that only one test case is used for testing, under the condition that the test case passes the test, the problem of software codes cannot be tested, and all the problem angles expected by designing the test case cannot be covered, so that the embodiment of the invention utilizes a genetic programming algorithm, and when a new test case execution path is generated, the number of test cases is randomly increased, and the number of tests of a plurality of test cases is reduced on the premise of optimizing the path, and the same test case is used for two or more times of testing, so that problems can be found conveniently, the test effect is better, and the larger the scale of the test case is, the better the effect of the method for generating the test case execution path is.
In summary, as shown in fig. 11, the embodiment of the invention provides a whole flow of a method for generating an execution path of a test case. According to the method for generating the test case execution path, the first weight value is set as the corresponding priority according to the historical execution result of the test case, so that an initial population is generated according to the priority; by utilizing the advantages of strong global searching capability and high convergence rate of the genetic programming algorithm, the optimal test case execution path is determined by considering actual output, expected output, code coverage rate and execution time, so that unnecessary test cases are reduced, the problems of wasting execution time and resource cost are solved, the coverage rate and coverage accuracy of the test case execution path are improved, more program defects and errors are detected, and the regression test effect is improved; and by means of a nested particle swarm algorithm, the performance and the robustness of the generation method of the test case execution path are improved, and the genetic programming algorithm is prevented from falling into a local optimal solution.
Example 2:
on the basis of the method for generating the test case execution path provided in the above embodiment 1, the present invention further provides a device for generating the test case execution path, which can be used to implement the method, as shown in fig. 12, and is a schematic architecture diagram of the device for generating the test case execution path according to the embodiment of the present invention. The apparatus of the present embodiment includes one or more processors 21 and a memory 22. In fig. 12, a processor 21 is taken as an example.
The processor 21 and the memory 22 may be connected by a bus or otherwise, which is illustrated in fig. 12 as a bus connection.
The memory 22 is used as a nonvolatile computer-readable storage medium for storing a nonvolatile software program and a nonvolatile computer-executable program, and is used for generating a test case execution path as in embodiment 1. The processor 21 executes the method of generating the test case execution path by running non-volatile software programs and instructions stored in the memory 22.
The memory 22 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 22 may optionally include memory located remotely from processor 21, which may be connected to processor 21 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The program instructions/modules are stored in the memory 22, and when executed by the one or more processors 21, perform the method of generating test case execution paths in embodiment 1 described above, for example, performing the steps described in the above embodiments.
It should be noted that, because the content of information interaction and execution process between modules and units in the above-mentioned device and system is based on the same concept as the processing method embodiment of the present invention, specific content may be referred to the description in the method embodiment of the present invention, and will not be repeated here.
Those of ordinary skill in the art will appreciate that all or a portion of the steps in the various methods of the embodiments may be implemented by a program that instructs associated hardware, the program may be stored on a computer readable storage medium, the storage medium may include: read Only Memory (ROM), random access Memory (RAM, random Access Memory), magnetic or optical disk, and the like.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, and alternatives falling within the spirit and principles of the invention.

Claims (10)

1. A method for generating a test case execution path, the method comprising:
acquiring a test case set, and calculating a first weight value corresponding to each test case in the test case set according to a historical execution result corresponding to the test case set;
acquiring an execution path of at least one group of test cases according to the test case set and the corresponding first weight value, and forming an initial population according to at least one execution path;
carrying out local optimization on the initial population to obtain a local result set, and carrying out evolutionary computation on the local result set according to an fitness function; carrying out local optimization and evolution calculation once each time, and carrying out local optimization and evolution calculation once again according to the result of the previous evolution calculation until a preset termination condition is met;
and after the preset termination condition is met, a candidate result set is obtained, and an execution path with highest fitness is obtained according to the candidate result set.
2. The method for generating a test case execution path according to claim 1, wherein the obtaining the test case set, and calculating the first weight value corresponding to each test case in the test case set according to the historical execution result corresponding to the test case set comprises:
Determining a difference between an expected output of the historical execution result and an actual output of the historical execution result as a first difference;
determining the ratio of the first difference value to the expected output as a first ratio, and determining the difference value of a first preset value and the first ratio as an output intermediate value;
carrying out logarithmic operation on the execution time of the historical execution result with the preset base number as the base to obtain a first logarithmic value, and determining the sum of the first logarithmic value and the first preset value as an execution intermediate value;
determining the sum of the program error number of the historical execution result and the first preset value as an error intermediate value;
the product of the output intermediate value and the execution intermediate value and the error intermediate value is determined as the first weight value.
3. The method for generating test case execution paths according to claim 1, wherein the local optimization is performed on the initial population to obtain a local result set, and evolutionary computation is performed on the local result set according to a fitness function; and carrying out the local optimization and the evolution calculation once each time, and carrying out the local optimization and the evolution calculation once again according to the result of the previous evolution calculation until the preset termination condition is met, wherein the steps of:
Carrying out local optimization on the initial population to obtain a local result set;
calculating fitness of all individuals of the local result set according to a fitness function, wherein one individual corresponds to one execution path;
sorting the individuals according to the corresponding fitness, selecting a preset number of individuals with the front sorting, and taking the individuals as father;
generating a plurality of filial generations according to the father generation, and constructing the new generation population according to the father generation and the filial generation until the population size of the new generation population is the same as the population size of the initial population, so as to generate the new generation population;
and after each time of local optimization and evolution calculation, taking the new generation population as the initial population, and carrying out the next local optimization and the next evolution calculation until a preset termination condition is met.
4. The method of claim 3, wherein the locally optimizing the initial population to obtain a local result set comprises:
randomly acquiring at least one individual according to the initial population, and randomly generating the current position and the current speed of the individual according to a preset rule;
In each iteration, determining a difference value between a historical optimal position and the current position as a second difference value, determining a difference value between a global optimal position and the current position as a third difference value, determining a product of a current speed of the individual in a previous iteration and a preset inertia weight as a first inertia value, determining a product of a first random number and a first acceleration coefficient and the second difference value as an individual cognition value, determining a product of a second random number and a second acceleration coefficient and the third difference value as a social cognition value, determining a sum of the first inertia value and the individual cognition value and the social cognition value as a current speed of a next iteration, and determining a sum of the current position and the current speed of the next iteration as a current position of the next iteration;
in each iteration, calculating the local fitness of all the individuals according to the current position, obtaining a historical optimal position of the current iteration and a global optimal position of the current iteration according to a local optimization rule and the local fitness, and determining the current speed of the next iteration and the current position of the next iteration according to the historical optimal position and the global optimal position until a local termination condition is met;
And after the local termination condition is met, obtaining the local result set.
5. The method of claim 3, wherein calculating fitness of all individuals of the local result set according to a fitness function, wherein one of the individuals corresponds to one of the execution paths comprises:
calculating a first accuracy value of the test case in each local result set according to a preset accuracy rule and the historical execution result; determining the sum of the first accuracy values of the test cases corresponding to the individuals as a second accuracy value of the individuals, and determining the product of the second accuracy value and the accuracy weight as a third accuracy value;
determining the ratio of the total number of functional modules covered by one individual to the total number of functional modules covered by all test cases in the local result set as a second ratio, and determining the product of the second ratio and coverage rate weight as a coverage rate value;
determining the ratio of the sum of the execution time of all the test cases in the individual to the sum of the execution time of all the test cases in the local result set as a third ratio, and determining the product of the third ratio and the efficiency weight as an efficiency value;
And determining the sum of the third accuracy value, the coverage value and the efficiency value as the fitness of the individual.
6. The method for generating test case execution paths according to claim 3, wherein the ranking the individuals according to the respective fitness, selecting a preset number of the individuals ranked first, and using the individuals as parents comprises:
determining the sum of all the fitness degrees as the total fitness degree;
determining a ratio of fitness of each of the individuals to the total fitness as a selection probability for each of the individuals;
and sorting the selection probabilities, selecting a preset number of individuals with the top sorting, and taking the individuals as parents.
7. The method of claim 3, wherein generating a plurality of offspring from the parent, and constructing the new generation population from the parent and the offspring until the population size of the new generation population is the same as the population size of the initial population, comprises:
randomly acquiring two father parents, and performing cross operation to obtain two first offspring;
Performing mutation operation on the two first filial generations to obtain two second filial generations;
the two first offspring and the two second offspring are used as part of the new generation population;
and in each iteration, performing at least one cross operation and at least one mutation operation until the population size of the new generation population is the same as the population size of the initial population, and generating the new generation population.
8. The method for generating test case execution paths according to claim 7, wherein the randomly acquiring the two parents, performing a cross operation, and obtaining the two first children includes:
randomly acquiring two father parents which are respectively used as a first father parent and a second father parent;
sequentially obtaining intervals with the length of [ a, b ] in the first parent as a first interval; sequentially obtaining intervals with the length of [ a, b ] in the second parent as second intervals; wherein 0< a < b, a and b are both random values that are less than the length of the first parent and random values of the second parent simultaneously;
the data of the second interval is replaced by the data of the first interval, the data of other intervals of the second parent are kept unchanged, and the first child is obtained according to the replaced data and the original data;
And replacing the data of the first interval with the data of the second interval, wherein the data of other intervals of the first parent are kept unchanged, and the other first child is obtained according to the replaced data and the original data.
9. The method for generating test case execution paths according to claim 7, wherein the performing mutation operation on the two first children respectively, to obtain two second children includes:
sequentially obtaining one test case with the position c in the first offspring as a first test case; wherein c >0 and c is a random value less than the length of the first child;
sequentially acquiring one test case with the position d in the first offspring as a second test case; wherein d >0 and d is a random value less than the length of the first child;
and in the first offspring, exchanging the position of the first test case with the position of the second test case to obtain the second offspring.
10. The device for generating the test case execution path is characterized by comprising at least one processor and a memory, wherein the at least one processor and the memory are connected through a data bus, the memory stores instructions which can be executed by the at least one processor, and the instructions are used for completing the method for generating the test case execution path according to any one of claims 1-9 after being executed by the processor.
CN202310856287.7A 2023-07-12 2023-07-12 Method and corresponding device for generating test case execution path Pending CN117149615A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310856287.7A CN117149615A (en) 2023-07-12 2023-07-12 Method and corresponding device for generating test case execution path

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310856287.7A CN117149615A (en) 2023-07-12 2023-07-12 Method and corresponding device for generating test case execution path

Publications (1)

Publication Number Publication Date
CN117149615A true CN117149615A (en) 2023-12-01

Family

ID=88905031

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310856287.7A Pending CN117149615A (en) 2023-07-12 2023-07-12 Method and corresponding device for generating test case execution path

Country Status (1)

Country Link
CN (1) CN117149615A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117632770A (en) * 2024-01-25 2024-03-01 江西财经大学 Multipath coverage test case generation method and system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117632770A (en) * 2024-01-25 2024-03-01 江西财经大学 Multipath coverage test case generation method and system
CN117632770B (en) * 2024-01-25 2024-04-19 江西财经大学 Multipath coverage test case generation method and system

Similar Documents

Publication Publication Date Title
CN108563555B (en) Fault change code prediction method based on four-target optimization
US7725409B2 (en) Gene expression programming based on Hidden Markov Models
CN110059015B (en) Method for sequencing priorities of population evolution multi-target test cases
Bouchachia An immune genetic algorithm for software test data generation
CN110377511B (en) Test case generation method oriented to data flow
CN111275172A (en) Feedforward neural network structure searching method based on search space optimization
CN117149615A (en) Method and corresponding device for generating test case execution path
CN113687821A (en) Intelligent code splicing method based on graphic visualization
CN112364352A (en) Interpretable software vulnerability detection and recommendation method and system
Liu et al. Genetic programming model for software quality classification
CN114626071A (en) Vulnerability-oriented fuzzy test method, system and medium
CN116432570A (en) Method and device for generating test case of chip and storage medium
Rao et al. Optimizing the software testing efficiency by using a genetic algorithm: a design methodology
CN111444079B (en) Software defect repairing method and device
CN112783513B (en) Code risk checking method, device and equipment
Zheng et al. Data-driven optimization based on random forest surrogate
CN116010291A (en) Multipath coverage test method based on equalization optimization theory and gray prediction model
CN112181420B (en) Compiler defect positioning method based on reinforcement learning
CN111026661B (en) Comprehensive testing method and system for software usability
CN113377676A (en) Solver performance defect detection method based on multi-target genetic algorithm
CN110221838B (en) Method for carrying out automatic program design optimization based on genetic algorithm and directed acyclic graph
LIU et al. MC/DC Test Data Generation Algorithm Based on Whale Genetic Algorithm
Serdyukov et al. Using genetic algorithm for generating optimal data sets to automatic testing the program code
Joseph et al. Hybrid test case optimization approach using genetic algorithm with adaptive neuro fuzzy inference system for regression testing
Khaleel et al. Building a Tool for Optimal Test Cases Selection using Artificial Intelligence Techniques

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination