Test case generation method and device and control equipment
1. A method for generating a test case is characterized by comprising the following steps:
acquiring entry conditions of a target path of tested software, wherein the entry conditions comprise one or more formulas;
acquiring parameter values of a plurality of parameters written in the formula;
judging whether the judgment of each formula is true when each parameter value is written into the formula;
if the judgment of at least one formula is false, the parameter value is adjusted aiming at each formula judged to be false until the judgment of each formula is true;
and executing the target path, and recording the parameter value of the parameter and the execution result of the target path when the judgment of each formula is true.
2. The method of generating as claimed in claim 1, wherein after determining whether the determination of each of the formulas is true when each of the parameter values is written into the formula, the method further comprises:
and if the judgment of each formula is true, executing the target path, and recording the parameter value of each parameter and the execution result of the target path.
3. The generation method according to claim 1, wherein the performing the parameter value adjustment separately for each formula determined as false comprises:
determining a first formula judged to be false in the formulas as a target formula, and determining parameter values of all parameters of the target formula;
adjusting each parameter value to make the judgment of the target formula true;
and determining a second formula judged to be false in the plurality of formulas as a target formula, and repeatedly executing the process until the judgment of each formula is true.
4. The method according to claim 3, wherein said adjusting each of said parameter values to make the determination of said target formula true comprises:
increasing the parameter value of the first parameter in the target formula by a precision, and judging whether the target formula approaches to be judged as true;
if the target formula approaches to be judged to be true, increasing the precision of the parameter value of the first parameter, and judging whether the target formula approaches to be judged to be true or not until the approach trend stops or the target formula is judged to be true.
5. The generation method according to claim 4, characterized in that, until after the trend of approach stops, the generation method further comprises:
and increasing the parameter value of the next parameter in the target formula by a precision, and judging whether the target formula approaches to be judged as true or not until the approach trend stops or the target formula is judged as true.
6. The method according to claim 4, wherein the generating method further comprises increasing the parameter value of the first parameter in the target formula by an accuracy and determining whether the target formula approaches the judgment result of being true, and then:
if the target formula is far away from the judgment result, reducing the parameter value of the first parameter by one precision, and judging whether the target formula approaches to the judgment result;
if the target formula approaches to be judged to be true, reducing the parameter value of the first parameter by one precision, and judging whether the target formula approaches to be judged to be true or not until the approach trend stops or the target formula is judged to be true.
7. The generation method according to claim 1 or 2, characterized in that after executing the target path, the generation method further comprises:
acquiring the times of the target path needing to be executed;
and judging whether the judgment of each formula is true or not according to the execution result of the target path until the target path is executed for the times.
8. An apparatus for generating a test case, comprising:
the system comprises a condition acquisition module, a condition analysis module and a condition analysis module, wherein the condition acquisition module is used for acquiring the entry condition of a target path of the software to be tested, and the entry condition comprises one or more formulas;
the parameter acquisition module is used for acquiring parameter values of a plurality of parameters written in the formula;
the result judging module is used for judging whether the judgment of each formula is true when each parameter value is written into the formula;
the parameter adjusting module is used for adjusting the parameter values of the formulas which are judged to be false respectively until the judgment of each formula is true if the judgment of at least one formula is false;
and the path execution module is used for executing the target path and recording the parameter value of the parameter and the execution result of the target path when the judgment of each formula is true.
9. The generation apparatus according to claim 8, characterized in that the generation apparatus further comprises:
and the execution recording module is used for executing the target path if the judgment of each formula is true, and recording the parameter value of each parameter and the execution result of the target path.
10. The generation apparatus of claim 8, wherein the parameter adjustment module comprises:
the first processing submodule is used for determining a first formula judged to be false in the formulas as a target formula and determining parameter values of all parameters of the target formula;
the parameter adjusting submodule is used for adjusting each parameter value to ensure that the judgment of the target formula is true;
and the second processing submodule is used for determining a second formula which is judged to be false in the formulas as a target formula and repeatedly executing the process until the judgment of each formula is true.
11. The generation apparatus of claim 10, wherein the parameter adjustment submodule comprises:
the first processing unit is used for increasing the parameter value of the first parameter in the target formula by one precision and judging whether the target formula approaches to be judged as true;
and the second processing unit is used for increasing the parameter value of the first parameter by one more precision if the target formula approaches to be judged as true, and judging whether the target formula approaches to be judged as true or not until the approach trend stops or the target formula is judged as true.
12. The generation apparatus of claim 11, wherein the parameter adjustment submodule further comprises:
and the third processing unit is used for increasing the parameter value of the next parameter in the target formula by one precision when the approach trend stops, and judging whether the target formula approaches to be judged as true or not until the approach trend stops or the target formula is judged as true.
13. The generation apparatus of claim 11, wherein the parameter adjustment submodule further comprises:
the fourth processing unit is used for reducing the parameter value of the first parameter by one precision if the target formula is far away from the judgment result and judging whether the target formula approaches the judgment result;
and the fifth processing unit is used for reducing the parameter value of the first parameter by one precision if the target formula approaches to be judged as true, and judging whether the target formula approaches to be judged as true or not until the approach trend stops or the target formula is judged as true.
14. The generation apparatus according to claim 8 or 9, characterized in that the generation apparatus further comprises:
the frequency acquisition module is used for acquiring the frequency of the target path to be executed;
and the judgment processing module is used for judging whether the judgment of each formula is true according to the execution result of the target path until the target path is executed for the times.
15. A control apparatus comprising a memory, a processor and a computer program stored on the memory and executable on the processor; characterized in that the processor, when executing the program, implements the generation method according to any one of claims 1 to 7.
Background
At the present stage, as the function logic of the whole vehicle is more and more complex, the corresponding test work also needs to be synchronously followed. For a test case of formula calculation, test input needs to be adjusted according to a calculation formula, loop iteration is usually required for several cycles, and whether a result calculated each time meets an expected result is observed respectively.
Because formula calculation software is built based on stateflow, the software can be always in an expected path by keeping the input of test input when the path coverage test is carried out, the input value needs to be manually calculated and adjusted at present, the efficiency of manually calculating and adjusting the input value is low, errors are easy to occur in the calculation process, and time and labor are consumed relatively, so that the method is inconvenient.
Disclosure of Invention
The embodiment of the invention provides a test case generation method, a test case generation device and control equipment, which are used for solving the problems of low efficiency and high error probability in the existing test process.
In order to solve the technical problems, the invention adopts the following technical scheme:
according to an aspect of the present invention, a method for generating a test case is provided, including:
acquiring entry conditions of a target path of tested software, wherein the entry conditions comprise one or more formulas;
acquiring parameter values of a plurality of parameters written in the formula;
judging whether the judgment of each formula is true when each parameter value is written into the formula;
if the judgment of at least one formula is false, the parameter value is adjusted aiming at each formula judged to be false until the judgment of each formula is true;
and executing the target path, and recording the parameter value of the parameter and the execution result of the target path when the judgment of each formula is true.
Optionally, when determining that each parameter value is written into the formula, after determining whether the determination of each formula is true, the generating method further includes:
and if the judgment of each formula is true, executing the target path, and recording the parameter value of each parameter and the execution result of the target path.
Optionally, the performing, for each formula determined to be false, the parameter value adjustment separately includes:
determining a first formula judged to be false in the formulas as a target formula, and determining parameter values of all parameters of the target formula;
adjusting each parameter value to make the judgment of the target formula true;
and determining a second formula judged to be false in the plurality of formulas as a target formula, and repeatedly executing the process until the judgment of each formula is true.
Optionally, the adjusting each parameter value to make the determination of the target formula true includes:
increasing the parameter value of the first parameter in the target formula by a precision, and judging whether the target formula approaches to be judged as true;
if the target formula approaches to be judged to be true, increasing the precision of the parameter value of the first parameter, and judging whether the target formula approaches to be judged to be true or not until the approach trend stops or the target formula is judged to be true.
Optionally, after the approach trend stops, the generating method further includes:
and increasing the parameter value of the next parameter in the target formula by a precision, and judging whether the target formula approaches to be judged as true or not until the approach trend stops or the target formula is judged as true.
Optionally, after increasing the parameter value of the first parameter in the target formula by an accuracy and determining whether the target formula approaches to be determined as true, the generating method further includes:
if the target formula is far away from the judgment result, reducing the parameter value of the first parameter by one precision, and judging whether the target formula approaches to the judgment result;
if the target formula approaches to be judged to be true, reducing the parameter value of the first parameter by one precision, and judging whether the target formula approaches to be judged to be true or not until the approach trend stops or the target formula is judged to be true.
Optionally, after executing the target path, the generating method further includes:
acquiring the times of the target path needing to be executed;
and judging whether the judgment of each formula is true or not according to the execution result of the target path until the target path is executed for the times.
According to another aspect of the present invention, there is provided a test case generation apparatus, including:
the system comprises a condition acquisition module, a condition analysis module and a condition analysis module, wherein the condition acquisition module is used for acquiring the entry condition of a target path of the software to be tested, and the entry condition comprises one or more formulas;
the parameter acquisition module is used for acquiring parameter values of a plurality of parameters written in the formula;
the result judging module is used for judging whether the judgment of each formula is true when each parameter value is written into the formula;
the parameter adjusting module is used for adjusting the parameter values of the formulas which are judged to be false respectively until the judgment of each formula is true if the judgment of at least one formula is false;
and the path execution module is used for executing the target path and recording the parameter value of the parameter and the execution result of the target path when the judgment of each formula is true.
Optionally, the generating device further includes:
and the execution recording module is used for executing the target path if the judgment of each formula is true, and recording the parameter value of each parameter and the execution result of the target path.
Optionally, the parameter adjusting module includes:
the first processing submodule is used for determining a first formula judged to be false in the formulas as a target formula and determining parameter values of all parameters of the target formula;
the parameter adjusting submodule is used for adjusting each parameter value to ensure that the judgment of the target formula is true;
and the second processing submodule is used for determining a second formula which is judged to be false in the formulas as a target formula and repeatedly executing the process until the judgment of each formula is true.
Optionally, the parameter adjusting sub-module includes:
the first processing unit is used for increasing the parameter value of the first parameter in the target formula by one precision and judging whether the target formula approaches to be judged as true;
and the second processing unit is used for increasing the parameter value of the first parameter by one more precision if the target formula approaches to be judged as true, and judging whether the target formula approaches to be judged as true or not until the approach trend stops or the target formula is judged as true.
Optionally, the parameter adjusting sub-module further includes:
and the third processing unit is used for increasing the parameter value of the next parameter in the target formula by one precision when the approach trend stops, and judging whether the target formula approaches to be judged as true or not until the approach trend stops or the target formula is judged as true.
Optionally, the parameter adjusting sub-module further includes:
the fourth processing unit is used for reducing the parameter value of the first parameter by one precision if the target formula is far away from the judgment result and judging whether the target formula approaches the judgment result;
and the fifth processing unit is used for reducing the parameter value of the first parameter by one precision if the target formula approaches to be judged as true, and judging whether the target formula approaches to be judged as true or not until the approach trend stops or the target formula is judged as true.
Optionally, the generating device further includes:
the frequency acquisition module is used for acquiring the frequency of the target path to be executed;
and the judgment processing module is used for judging whether the judgment of each formula is true according to the execution result of the target path until the target path is executed for the times.
According to another aspect of the present invention, there is provided a control apparatus comprising a memory, a processor and a computer program stored on the memory and executable on the processor; the processor, when executing the program, implements the generation method as described above.
The invention has the beneficial effects that:
according to the scheme, the strong computing power of the computer is utilized, the previous manual computing part is computed by executing the preset software logic, and the loop iteration is automatically carried out according to the formula, so that the computing speed is high, the accuracy is high, the manpower and time cost are saved, and the method is more convenient.
Drawings
Fig. 1 is a schematic diagram illustrating a method for generating a test case according to an embodiment of the present invention;
fig. 2 is a schematic diagram illustrating a device for generating a test case according to an embodiment of the present invention;
fig. 3 is a flowchart illustrating a method for generating a test case according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
The invention provides a method, a device and control equipment for generating a test case, aiming at the problems that in the prior art, a calculation method is low in efficiency and easy to make mistakes in testing.
As shown in fig. 1, an embodiment of the present invention provides a method for generating a test case, including:
s11: and acquiring the entry condition of the target path of the tested software, wherein the entry condition comprises one or more formulas.
It should be noted that the test case generation method provided by the invention is suitable for the software of the formula calculation class, and the input value of the test case and the corresponding expected output result are generated aiming at the software of the formula calculation class, so that the time and the labor are saved.
S12: parameter values of a plurality of parameters written in the formula are obtained.
It should be noted that, according to one embodiment of the present invention, the tested software logic is described as: if A + B > C, then Path one is executed; if A + B < C, path two is executed; if a + B ═ C, then path three is performed. The software to be tested runs in a period of 0.1 second, the calculation result of the previous period is introduced into the next period to continue calculation, and the parameter values of the three A/B/C parameters are influenced.
Specifically, when testing such software, taking path one as an example: in order to ensure that the software can normally run, firstly, the data type, the precision and the value range of the three signals of A/B/C are required to be determined, and accordingly, the initial values of the three signals can be defined, wherein the data type, the precision and the value range can be obtained from the functional description of the software to be tested; then, key word indexes of the three signals of A/B/C are defined, namely, the positions of the three signals are assigned or valued, and the numerical values of a plurality of cycles need to be deduced, namely, the target path is repeatedly executed for a plurality of times.
S13: and judging whether the judgment of each formula is true when each parameter value is written into the formula.
It should be noted that, according to an embodiment of the present invention, taking path one as an example, the entry condition judgment formula of the measured path is imported, that is, the entry condition a + B > C of the target path of the measured software is obtained. Acquiring initial values of the three A/B/C signals, namely initial parameter values of the three parameters, through key word indexes of the three A/B/C signals, judging whether A + B > C is true, and processing the values of the three A/B/C signals according to a judgment result, namely recording or adjusting the parameter values of the parameters.
S14: if the judgment of at least one formula is false, the parameter value is adjusted aiming at each formula judged to be false until the judgment of each formula is true;
s15: and executing the target path, and recording the parameter value of the parameter and the execution result of the target path when the judgment of each formula is true.
Optionally, when determining that each parameter value is written into the formula, after determining whether the determination of each formula is true, the generating method further includes:
and if the judgment of each formula is true, executing the target path, and recording the parameter value of each parameter and the execution result of the target path.
In the above embodiment, if a + B > C is determined as true, the parameter values of the three parameters a/B/C and the result of the execution target path (i.e., path one) are filled in the specified position in the test case, and the simulation calculation of the next cycle is performed; if the judgment result is false, the initial value setting is unreasonable, and the initial value settings of the three A/B/C signals need to be readjusted.
It should also be noted that in actual work, the formula we encounter can be more complex than the formula decision of A + B > C, and ABC itself can be the result of loop nesting of multiple formulas. When such complex formula calculation is automatically derived, all formulas and all parameters should be enumerated, and judgment should be made for all formulas. According to another embodiment of the invention, the tested software logic is described as: if A + B > C and D + E > F, then Path one is performed; if A + B < C and D + E < F, path two is performed; if a + B equals C and D + E equals F, then path three is performed. When the path I is taken as a target path, the entry conditions are A + B > C and D + E > F, and after the initial value of the parameters A/B/C/D/E/F is obtained, the true and false of the formula are judged: and if the A + B > C and the D + E > F are judged to be true, recording the parameter values of the parameters A/B/C/D/E/F and the execution result of the execution path I, and filling the corresponding positions of the test cases. If the formulas of A + B > C and D + E > F are judged to be false, the parameter values of the parameters A/B/C/D/E/F need to be adjusted in sequence until the A + B > C and the D + E > F are judged to be true.
Specifically, for the parameters in the formula determined as being false, values should be selected one by one on the left and right sides of the formula, and it is determined whether the adjusted parameter values can make the formula determined as being false more approximate to the determination result until all the formulas are determined to be true, at this time, the parameter values and the output result after the target path is executed are recorded as the input and the expected output result in the test case.
Optionally, the performing, for each formula determined to be false, the parameter value adjustment separately includes:
determining a first formula judged to be false in the formulas as a target formula, and determining parameter values of all parameters of the target formula;
adjusting each parameter value to make the judgment of the target formula true;
and determining a second formula judged to be false in the plurality of formulas as a target formula, and repeatedly executing the process until the judgment of each formula is true.
It should be noted that the target path may be executed only when the determinations of all the formulas in the entry condition are true, and therefore, the formulas determined as being false need to be adjusted in sequence until all the formulas are determined as being true.
Optionally, the adjusting each parameter value to make the determination of the target formula true includes:
increasing the parameter value of the first parameter in the target formula by a precision, and judging whether the target formula approaches to be judged as true;
if the target formula approaches to be judged to be true, increasing the precision of the parameter value of the first parameter, and judging whether the target formula approaches to be judged to be true or not until the approach trend stops or the target formula is judged to be true.
The parameter values may be adjusted according to a tendency of the target formula approaching the true determination. Firstly, trying to increase a precision on a parameter value of a parameter to be adjusted, if the adjusted parameter value enables the target formula to be closer to judgment of true, indicating that the adjustment direction is correct, and further increasing a precision on the parameter value to continue judgment; if the target formula is far away from the judgment result after the adjustment is true, the adjustment direction is wrong, and the continuous judgment of reducing the parameter value by one precision can be tried.
Optionally, after the approach trend stops, the generating method further includes:
and increasing the parameter value of the next parameter in the target formula by a precision, and judging whether the target formula approaches to be judged as true or not until the approach trend stops or the target formula is judged as true.
It should be noted that, when the trend of convergence stops, which indicates that whether the parameter value for adjusting the parameter further approaches the target formula to be determined as true, an attempt to adjust the next parameter is started until the target formula is determined as true.
Optionally, after increasing the parameter value of the first parameter in the target formula by an accuracy and determining whether the target formula approaches to be determined as true, the generating method further includes:
if the target formula is far away from the judgment result, reducing the parameter value of the first parameter by one precision, and judging whether the target formula approaches to the judgment result;
if the target formula approaches to be judged to be true, reducing the parameter value of the first parameter by one precision, and judging whether the target formula approaches to be judged to be true or not until the approach trend stops or the target formula is judged to be true.
Optionally, after executing the target path, the generating method further includes:
acquiring the times of the target path needing to be executed;
and judging whether the judgment of each formula is true or not according to the execution result of the target path until the target path is executed for the times.
It should be noted that, since the software is operated periodically, the value calculated by the formula changes with the change of the calculation period, and the engineer can be liberated from the complicated formula calculation by the test case generation method provided by the embodiment of the present invention. Specifically, in practical application, the code of the generation method may be nested in a use case design tool. When a test case is designed according to the formula calculation requirement, the code is called, a user only needs to clearly fill various jump conditions (namely the entry conditions) of the software to be tested and a calculation formula (namely the target path) executed after jumping, the code is operated after an initial value is set, the target path can be executed according to set times, and input conditions and expected results of each time are calculated.
As shown in fig. 3, a flowchart of a method for generating a test case according to an embodiment of the present invention is shown:
s301: importing all formulas, namely acquiring the entry conditions of the target path of the tested software;
s302: reading parameter values of all parameters;
s303: judging all entry conditions of the target path, namely judging whether the judgment of each formula is true when each parameter value is written into the formula; if yes, go to S304; if not, executing S305;
s304: recording all values of the set, i.e. recording the parameter value of each of said parameters; executing the target path to obtain a group of new numerical values, namely an execution result of the target path; and carrying out judgment derivation of the next period.
S305: adding a precision to the parameter value of the first parameter of the first formula judged to be false, namely taking the first formula judged to be false as a target formula;
s306: judging whether the target formula is closer to the establishment of judgment; if yes, go to S307; otherwise, executing S313;
s307: continuously and successively increasing one unit precision on the parameter value of the parameter until the target formula is judged to be true; if the target formula is determined to be true, then S312 is executed; if the determination result is false, executing S308;
s308: judging whether the approach trend stops or not; if yes, go to S309; otherwise, executing S307;
s309: selecting the Nth parameter and increasing one unit precision, namely increasing one precision for the parameter value of the next parameter in the target formula;
s310: judging whether the target formula is closer to be judged as true or not; if yes, go to step S311; otherwise, executing S317;
s311: continuously and successively increasing one unit precision on the parameter value of the parameter until the target formula is judged to be true;
s312: and (4) approaching the next formula judged to be false to judge that the formula is true to adjust until all the formulas are judged to be true. Recording all values of the set, i.e. recording the parameter value of each of said parameters; executing the target path to obtain a group of new numerical values, namely an execution result of the target path; carrying out judgment derivation on the next period;
s313: continuously reducing the unit precision on the parameter value of the parameter until the target formula is judged to be true;
s314: judging whether the approach trend stops or not; if yes, go to S315; otherwise, executing S313;
s315: selecting the Nth parameter to reduce one unit precision, namely reducing the parameter value of the next parameter in the target formula by one precision;
s316: judging whether the target formula is closer to be judged as true or not; if yes, go to step S311; otherwise, executing S317;
s317: and continuously reducing the unit precision on the parameter value of the parameter in sequence until the target formula is judged to be true.
In the embodiment of the invention, the strong computing power of the computer is utilized, the previous manual computing part is computed by executing the preset software logic, and the loop iteration is automatically carried out according to the formula, so that the computing speed is high, the accuracy is high, the labor and time cost is saved, and the method is more convenient.
As shown in fig. 2, an embodiment of the present invention further provides a device for generating a test case, including:
the condition obtaining module 21 is configured to obtain entry conditions of a target path of the software under test, where the entry conditions include one or more formulas.
It should be noted that the test case generation device provided by the invention is suitable for the software of the formula calculation class, and the input value of the test case and the corresponding expected output result are generated aiming at the software of the formula calculation class, so that the time and the labor are saved.
A parameter obtaining module 22, configured to obtain parameter values of the plurality of parameters written in the formula.
It should be noted that, according to one embodiment of the present invention, the tested software logic is described as: if A + B > C, then Path one is executed; if A + B < C, path two is executed; if a + B ═ C, then path three is performed. The software to be tested runs in a period of 0.1 second, the calculation result of the previous period is introduced into the next period to continue calculation, and the parameter values of the three A/B/C parameters are influenced.
Specifically, when testing such software, taking path one as an example: in order to ensure that the software can normally run, firstly, the data type, the precision and the value range of the three signals of A/B/C are required to be determined, and accordingly, the initial values of the three signals can be defined, wherein the data type, the precision and the value range can be obtained from the functional description of the software to be tested; then, key word indexes of the three signals of A/B/C are defined, namely, the positions of the three signals are assigned or valued, and the numerical values of a plurality of cycles need to be deduced, namely, the target path is repeatedly executed for a plurality of times.
And the result judging module 23 is configured to judge whether the judgment of each formula is true when each parameter value is written in the formula.
It should be noted that, according to an embodiment of the present invention, taking path one as an example, the entry condition judgment formula of the measured path is imported, that is, the entry condition a + B > C of the target path of the measured software is obtained. Acquiring initial values of the three A/B/C signals, namely initial parameter values of the three parameters, through key word indexes of the three A/B/C signals, judging whether A + B > C is true, and processing the values of the three A/B/C signals according to a judgment result, namely recording or adjusting the parameter values of the parameters.
A parameter adjusting module 24, configured to, if the determination result of at least one of the formulas is false, adjust the parameter value of each of the formulas determined as false until the determination result of each of the formulas is true;
and a path executing module 25, configured to execute the target path, and record a parameter value of the parameter and an execution result of the target path when the determination of each formula is true.
Optionally, the generating device further includes:
and the execution recording module is used for executing the target path if the judgment of each formula is true, and recording the parameter value of each parameter and the execution result of the target path.
In the above embodiment, if a + B > C is determined as true, the parameter values of the three parameters a/B/C and the result of the execution target path (i.e., path one) are filled in the specified position in the test case, and the simulation calculation of the next cycle is performed; if the judgment result is false, the initial value setting is unreasonable, and the initial value settings of the three A/B/C signals need to be readjusted.
It should also be noted that in actual work, the formula we encounter can be more complex than the formula decision of A + B > C, and ABC itself can be the result of loop nesting of multiple formulas. When such complex formula calculation is automatically derived, all formulas and all parameters should be enumerated, and judgment should be made for all formulas. According to another embodiment of the invention, the tested software logic is described as: if A + B > C and D + E > F, then Path one is performed; if A + B < C and D + E < F, path two is performed; if a + B equals C and D + E equals F, then path three is performed. When the path I is taken as a target path, the entry conditions are A + B > C and D + E > F, and after the initial value of the parameters A/B/C/D/E/F is obtained, the true and false of the formula are judged: and if the A + B > C and the D + E > F are judged to be true, recording the parameter values of the parameters A/B/C/D/E/F and the execution result of the execution path I, and filling the corresponding positions of the test cases. If the formulas of A + B > C and D + E > F are judged to be false, the parameter values of the parameters A/B/C/D/E/F need to be adjusted in sequence until the A + B > C and the D + E > F are judged to be true.
Specifically, for the parameters in the formula determined as being false, values should be selected one by one on the left and right sides of the formula, and it is determined whether the adjusted parameter values can make the formula determined as being false more approximate to the determination result until all the formulas are determined to be true, at this time, the parameter values and the output result after the target path is executed are recorded as the input and the expected output result in the test case.
Optionally, the parameter adjusting module includes:
the first processing submodule is used for determining a first formula judged to be false in the formulas as a target formula and determining parameter values of all parameters of the target formula;
the parameter adjusting submodule is used for adjusting each parameter value to ensure that the judgment of the target formula is true;
and the second processing submodule is used for determining a second formula which is judged to be false in the formulas as a target formula and repeatedly executing the process until the judgment of each formula is true.
It should be noted that the target path may be executed only when the determinations of all the formulas in the entry condition are true, and therefore, the formulas determined as being false need to be adjusted in sequence until all the formulas are determined as being true.
The parameter values may be adjusted according to a tendency of the target formula approaching the true determination. Firstly, trying to increase a precision on a parameter value of a parameter to be adjusted, if the adjusted parameter value enables the target formula to be closer to judgment of true, indicating that the adjustment direction is correct, and further increasing a precision on the parameter value to continue judgment; if the target formula is far away from the judgment result after the adjustment is true, the adjustment direction is wrong, and the continuous judgment of reducing the parameter value by one precision can be tried.
Optionally, the parameter adjusting sub-module includes:
the first processing unit is used for increasing the parameter value of the first parameter in the target formula by one precision and judging whether the target formula approaches to be judged as true;
and the second processing unit is used for increasing the parameter value of the first parameter by one more precision if the target formula approaches to be judged as true, and judging whether the target formula approaches to be judged as true or not until the approach trend stops or the target formula is judged as true.
It should be noted that, when the trend of convergence stops, which indicates that whether the parameter value for adjusting the parameter further approaches the target formula to be determined as true, an attempt to adjust the next parameter is started until the target formula is determined as true.
Optionally, the parameter adjusting sub-module further includes:
and the third processing unit is used for increasing the parameter value of the next parameter in the target formula by one precision when the approach trend stops, and judging whether the target formula approaches to be judged as true or not until the approach trend stops or the target formula is judged as true.
Optionally, the parameter adjusting sub-module further includes:
the fourth processing unit is used for reducing the parameter value of the first parameter by one precision if the target formula is far away from the judgment result and judging whether the target formula approaches the judgment result;
and the fifth processing unit is used for reducing the parameter value of the first parameter by one precision if the target formula approaches to be judged as true, and judging whether the target formula approaches to be judged as true or not until the approach trend stops or the target formula is judged as true.
Optionally, the generating device further includes:
the frequency acquisition module is used for acquiring the frequency of the target path to be executed;
and the judgment processing module is used for judging whether the judgment of each formula is true according to the execution result of the target path until the target path is executed for the times.
It should be noted that, since the software is operated periodically, the value calculated by the formula changes with the change of the calculation period, and the test case generating device provided by the embodiment of the present invention can enable an engineer to be liberated from the complicated formula calculation. Specifically, in actual application, the generating device may be integrated in a use case designing tool. When designing a test case according to the formula calculation requirement, a user only needs to clearly fill various jump conditions (namely the entry conditions) of the software to be tested and a calculation formula (namely the target path) executed after jumping, and set an initial value, so that the target path can be executed according to the set times, and input conditions and expected results of each time are calculated.
In the embodiment of the invention, the strong computing power of the computer is utilized, the previous manual computing part is computed by executing the preset software logic, and the loop iteration is automatically carried out according to the formula, so that the computing speed is high, the accuracy is high, the labor and time cost is saved, and the method is more convenient.
The embodiment of the invention also provides control equipment, which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor; the processor, when executing the program, implements the generation method as described above.
While the preferred embodiments of the present invention have been described, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention as defined in the following claims.