CN113407435B - Test case generation method, device and control equipment - Google Patents
Test case generation method, device and control equipment Download PDFInfo
- Publication number
- CN113407435B CN113407435B CN202010185026.3A CN202010185026A CN113407435B CN 113407435 B CN113407435 B CN 113407435B CN 202010185026 A CN202010185026 A CN 202010185026A CN 113407435 B CN113407435 B CN 113407435B
- Authority
- CN
- China
- Prior art keywords
- formula
- true
- target
- parameter
- judgment
- 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.)
- Active
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 45
- 238000000034 method Methods 0.000 title claims abstract description 43
- 238000013459 approach Methods 0.000 claims description 48
- 238000012545 processing Methods 0.000 claims description 26
- 238000004590 computer program Methods 0.000 claims description 3
- 230000006870 function Effects 0.000 claims 2
- 238000004364 calculation method Methods 0.000 abstract description 42
- 238000013461 design Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000009191 jumping Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000004088 simulation Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000007423 decrease Effects 0.000 description 1
- 238000009795 derivation Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
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)
- Testing And Monitoring For Control Systems (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention provides a method, a device and control equipment for generating test cases, wherein the method comprises 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 into 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, respectively adjusting the parameter value according to 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. According to the scheme, the calculation is performed by executing the preset software logic on the part of the previous manual calculation by utilizing the powerful calculation capability of the computer, the loop iteration is automatically performed according to the formula, the calculation speed is high, the accuracy is high, the labor and time cost is saved, and the method is more convenient.
Description
Technical Field
The present invention relates to the field of automobiles, and in particular, to a method, an apparatus, and a control device for generating test cases.
Background
At present, as the whole vehicle functional logic becomes more and more complex, corresponding test work also needs to be synchronously followed. For the test cases of the formula calculation class, the test input needs to be adjusted according to the calculation formula, and a plurality of cycles are generally needed to be iterated in a circulating way, and whether the calculated result meets the expected result or not is respectively observed.
Because the software of formula calculation class is based on stateflow and is built, need keep the input of test input to be in the expected route all the time when carrying out the route coverage test, this work needs manual calculation adjustment input value at present, and manual calculation adjustment input value efficiency is lower, and the calculation process easily appears the mistake, compares time consuming and manpower, and is comparatively inconvenient.
Disclosure of Invention
The embodiment of the invention provides a method, a device and control equipment for generating test cases, which are used for solving the problems of low efficiency and easy error in the calculation process in the existing test.
In order to solve the technical problems, the invention adopts the following technical scheme:
According to one aspect of the present invention, there is provided a method for generating a test case, 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 into 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, respectively adjusting the parameter value according to 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, after determining whether the determination of each of the formulas is true when determining that each of the parameter values is written into the formulas, 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 adjusting the parameter value for each formula determined to be false includes:
Determining a first formula which is judged to be false in the formulas as a target formula, and determining parameter values of various parameters of the target formula;
adjusting each parameter value to make the judgment of the target formula true;
and 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, said adjusting each of said parameter values to make the determination of said target formula true includes:
Increasing the parameter value of the first parameter in the target formula by one precision, and judging whether the target formula approaches to the true value;
If the target formula approaches to true, the parameter value of the first parameter is increased by one precision, and whether the target formula approaches to true is judged, until the approaching trend stops or the target formula is judged to be true.
Optionally, after the approaching trend stops, the generating method further includes:
and increasing the parameter value of the next parameter in the target formula by one precision, and judging whether the target formula approaches to the judgment as true or not until the approaching trend stops or the target formula judges as true.
Optionally, the generating method further includes, after increasing the parameter value of the first parameter in the target formula by one precision and determining whether the target formula approaches to the decision as true:
If the target formula is far from the true, reducing the parameter value of the first parameter by one precision, and judging whether the target formula approaches to the true;
If the target formula approaches to true, reducing the parameter value of the first parameter by one precision, and judging whether the target formula approaches to true or not until the approaching trend stops or the target formula is judged to be true.
Optionally, after executing the target path, the generating method further includes:
Acquiring the number of times that the target path needs to be executed;
And 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 test case generating apparatus, including:
The condition acquisition module is used for acquiring the entry condition of the target path of the tested software, wherein 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 adjustment module is used for respectively adjusting the parameter value for each formula judged to be false if the judgment of at least one formula is false until the judgment of each formula is true;
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 adjustment module includes:
the first processing submodule is used for determining a first formula which is judged to be false in the formulas as a target formula and determining parameter values of various parameters of the target formula;
a parameter adjustment sub-module, configured to adjust each parameter value to make the determination of the target formula 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 adjustment submodule 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 the judgment of true;
and the second processing unit is used for increasing the parameter value of the first parameter by one precision if the target formula approaches to the judgment of true, and judging whether the target formula approaches to the judgment of true or not until the approaching trend stops or the target formula judges to be true.
Optionally, the parameter adjustment 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 approaching trend stops, and judging whether the target formula approaches to the true judgment until the approaching trend stops or the target formula judges the true judgment.
Optionally, the parameter adjustment sub-module further includes:
A fourth processing unit, configured to reduce the parameter value of the first parameter by one precision if the target formula is far from the true, and determine whether the target formula approaches the true;
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 the judgment of true, and judging whether the target formula approaches to the judgment of true or not until the approaching trend stops or the target formula judges to be 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 judging and 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 device 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 beneficial effects of the invention are as follows:
according to the scheme, the calculation is performed by executing the preset software logic on the part of the previous manual calculation by utilizing the powerful calculation capability of the computer, the loop iteration is automatically performed according to the formula, the calculation speed is high, the accuracy is high, the labor and time cost is saved, and the method is more convenient.
Drawings
FIG. 1 shows a schematic diagram of a method for generating test cases according to an embodiment of the present invention;
FIG. 2 shows a schematic diagram of a device for generating test cases according to an embodiment of the present invention;
FIG. 3 shows a flowchart of a method for generating test cases according to an embodiment of the present invention.
Detailed Description
The present invention will be described in detail below with reference to the drawings and the specific embodiments thereof in order to make the objects, technical solutions and advantages of the present invention more apparent.
Aiming at the problems of low efficiency and easy error of a computing method in the prior art test, the invention provides a method, a device and control equipment for generating test cases.
As shown in FIG. 1, one embodiment of the present invention provides a method for generating test cases, which includes:
s11: entry conditions for a target path of the software under test are obtained, the entry conditions comprising one or more formulas.
It should be noted that, the method for generating the test case provided by the invention is suitable for the software of the formula calculation class, and generates the input value of the test case and the corresponding expected output result aiming at the software of the formula calculation class, thereby saving time and manpower.
S12: parameter values of a plurality of parameters written into the formula are obtained.
It should be noted that, according to one embodiment of the present invention, the software logic under test is described as: if A+B > C, then execute Path one; if A+B < C, then execute Path two; if a+b=c, path three is executed. 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 parameters A/B/C are influenced.
Specifically, when testing such software, take path one as an example: in order to ensure that software can normally run, firstly, the data type, the precision and the value range of three signals of A/B/C are required to be defined, 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, the key index of the three signals of A/B/C is defined, namely, the value is assigned or valued from the position of the three signals, and the numerical value of a plurality of periods needs 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 one embodiment of the present invention, taking the first path as an example, an entry condition judgment formula of the tested path is imported, that is, the entry condition a+b > C of the target path of the tested software is obtained. And acquiring initial values of the three signals of A/B/C, namely initial parameter values of the three parameters, judging whether the A+B > C is true or not through key index of the three signals of A/B/C, and then processing the values of the three signals of A/B/C according to the judging result, namely recording or adjusting the parameter values of the parameters.
S14: if the judgment of at least one formula is false, respectively adjusting the parameter value according to 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, after determining whether the determination of each of the formulas is true when determining that each of the parameter values is written into the formulas, 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.
It should be noted that, in the above embodiment, if a+b > C is determined to be true, the parameter values of the three parameters a/B/C and the result of executing the target path (i.e., path one) are filled in the designated position in the test case, and the simulation calculation of the next period is performed; if the judgment is false, the initial value setting is unreasonable, and the initial value setting of the A/B/C signals needs to be readjusted.
It should be further noted that in actual operation, the formula we encounter is more complex than the formula decision such as a+b > C, and ABC itself may also be the result of multiple formula loop nesting. When such complex formula calculations are automatically derived, all formulas and all parameters should be enumerated and decisions should be made for all formulas. According to yet another embodiment of the present invention, the software logic under test is described as: if A+B > C and D+E > F, then Path one is executed; if A+B < C and D+E < F, then path two is executed; if a+b=c and d+e=f, path three is performed. When the first path is taken as a target path, the entering conditions are A+B > C and D+E > F, and after the initial value of the parameter A/B/C/D/E/F is obtained, the true or false of the formula is judged: if the A+B > C and the D+E > F are both judged to be true, the parameter value of the parameter A/B/C/D/E/F and the execution result of the execution path I are recorded, and the corresponding position of the test case is filled. If A+B > C and D+E > F have formulas therein that determine false, then the parameter values of the parameters A/B/C/D/E/F need to be adjusted in sequence until both A+B > C and D+E > F are determined to be true.
Specifically, for the parameters in the formulas determined to be false, the values should be selected one by one from left to right, and whether the adjusted parameter values can enable the formulas determined to be false to be more close to the establishment of the determination is determined until all formulas are determined to be established, and at this time, the parameter values and the output result after the target path is executed are recorded and used as the input and expected output result in the test case.
Optionally, the adjusting the parameter value for each formula determined to be false includes:
Determining a first formula which is judged to be false in the formulas as a target formula, and determining parameter values of various parameters of the target formula;
adjusting each parameter value to make the judgment of the target formula true;
and 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 all the formulas in the entry condition are judged to be true, and therefore, the formulas judged to be false need to be sequentially adjusted in parameter value until all the formulas are judged to be true.
Optionally, said adjusting each of said parameter values to make the determination of said target formula true includes:
Increasing the parameter value of the first parameter in the target formula by one precision, and judging whether the target formula approaches to the true value;
If the target formula approaches to true, the parameter value of the first parameter is increased by one precision, and whether the target formula approaches to true is judged, until the approaching trend stops or the target formula is judged to be true.
The parameter value may be adjusted by approaching a trend determined to be true according to the target formula. 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 more approximate to the true judgment, indicating that the adjustment direction is correct, and further increasing the precision on the parameter value to continue judgment; if the target formula is far from the true after adjustment, the adjustment direction is wrong, and the parameter value can be reduced by one precision to continue judgment.
Optionally, after the approaching trend stops, the generating method further includes:
and increasing the parameter value of the next parameter in the target formula by one precision, and judging whether the target formula approaches to the judgment as true or not until the approaching trend stops or the target formula judges as true.
The tightening trend is stopped, and if the parameter value of the parameter is adjusted so that the target formula cannot be further approached to the judgment of true, the next parameter is tried to be adjusted until the target formula is judged to be true.
Optionally, the generating method further includes, after increasing the parameter value of the first parameter in the target formula by one precision and determining whether the target formula approaches to the decision as true:
If the target formula is far from the true, reducing the parameter value of the first parameter by one precision, and judging whether the target formula approaches to the true;
If the target formula approaches to true, reducing the parameter value of the first parameter by one precision, and judging whether the target formula approaches to true or not until the approaching trend stops or the target formula is judged to be true.
Optionally, after executing the target path, the generating method further includes:
Acquiring the number of times that the target path needs to be executed;
And 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, because the software performs the operation periodically, the numerical value calculated by the formula will change along with the change of the calculation period, and the method for generating the test case provided by the embodiment of the invention can make engineers liberated from complicated formula calculation. Specifically, in practical application, the code of the generating method can be nested in the use case design tool. When the test case is designed aiming at the calculation type requirement of a formula, the code is called, and a user only needs to fill out various jump conditions (namely the entering conditions) of the tested software and a calculation formula (namely the target path) executed after jumping clearly, and the code is operated after an initial value is set, so that the target path can be executed according to the set times, and the input condition and the expected result of each time are calculated.
As shown in fig. 3, a flowchart of a method for generating test cases according to an embodiment of the present invention is as follows:
s301: importing all formulas to obtain the entry condition 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, executing S304; if not, executing S305;
S304: recording all values of the set, i.e. recording the parameter values of each of said parameters; executing a target path to obtain a new set of values, namely an execution result of the target path; decision derivation is performed for the next cycle.
S305: increasing a precision for 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 more close to the establishment of the judgment; if yes, then execution S307; otherwise, executing S313;
s307: continuously increasing the unit precision on the parameter value of the parameter successively until the target formula is judged to be true; if the target formula is determined to be true, then S312 is performed; if yes, executing S308;
S308: judging whether the approach trend stops; if yes, then execution S309; if not, then S307 is performed;
S309: selecting an Nth parameter to increase a unit precision, namely increasing a parameter value of a next parameter in the target formula by a precision;
S310: judging whether the target formula is more approximate to the judgment as true; if yes, then execute S311; if not, then S317 is performed;
S311: continuously increasing the unit precision on the parameter value of the parameter successively until the target formula is judged to be true;
S312: and performing approach judgment as true adjustment on the next formula judged as false until all formulas are judged as true. Recording all values of the set, i.e. recording the parameter values of each of said parameters; executing a target path to obtain a new set of values, namely an execution result of the target path; performing judgment and deduction of the next period;
S313: successively reducing the parameter value of the parameter by one unit precision until the target formula is judged to be true;
S314: judging whether the approach trend stops; if yes, then execute S315; if not, then S313 is performed;
s315: selecting an Nth parameter to reduce the 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 more approximate to the judgment as true; if yes, then execute S311; if not, then S317 is performed;
S317: the successive decreases in parameter value for this parameter by one unit of accuracy continue until the target formula is determined to be true.
In the embodiment of the invention, the part of the previous manual calculation is calculated by executing the preset software logic by utilizing the strong calculation capability of the computer, and the loop iteration is automatically performed according to the formula, so that the calculation speed is high, the accuracy is high, the labor and time cost are 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 acquisition module 21 is configured to acquire an entry condition of a target path of the software under test, where the entry condition includes one or more formulas.
It should be noted that, the generating device of the test case provided by the invention is suitable for the software of the formula calculation class, and generates the input value of the test case and the corresponding expected output result aiming at the software of the formula calculation class, thereby saving time and manpower.
The parameter obtaining module 22 is configured to obtain parameter values of a plurality of parameters written in the formula.
It should be noted that, according to one embodiment of the present invention, the software logic under test is described as: if A+B > C, then execute Path one; if A+B < C, then execute Path two; if a+b=c, path three is executed. 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 parameters A/B/C are influenced.
Specifically, when testing such software, take path one as an example: in order to ensure that software can normally run, firstly, the data type, the precision and the value range of three signals of A/B/C are required to be defined, 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, the key index of the three signals of A/B/C is defined, namely, the value is assigned or valued from the position of the three signals, and the numerical value of a plurality of periods needs to be deduced, namely, the target path is repeatedly executed for a plurality of times.
The result determining module 23 is configured to determine whether the determination of each formula is true when each parameter value is written into the formula.
It should be noted that, according to one embodiment of the present invention, taking the first path as an example, an entry condition judgment formula of the tested path is imported, that is, the entry condition a+b > C of the target path of the tested software is obtained. And acquiring initial values of the three signals of A/B/C, namely initial parameter values of the three parameters, judging whether the A+B > C is true or not through key index of the three signals of A/B/C, and then processing the values of the three signals of A/B/C according to the judging result, namely recording or adjusting the parameter values of the parameters.
The parameter adjustment module 24 is configured to, if at least one of the formulas is determined to be false, respectively perform the parameter value adjustment for each of the formulas determined to be false until the determination of each of the formulas is true;
And a path execution 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.
It should be noted that, in the above embodiment, if a+b > C is determined to be true, the parameter values of the three parameters a/B/C and the result of executing the target path (i.e., path one) are filled in the designated position in the test case, and the simulation calculation of the next period is performed; if the judgment is false, the initial value setting is unreasonable, and the initial value setting of the A/B/C signals needs to be readjusted.
It should be further noted that in actual operation, the formula we encounter is more complex than the formula decision such as a+b > C, and ABC itself may also be the result of multiple formula loop nesting. When such complex formula calculations are automatically derived, all formulas and all parameters should be enumerated and decisions should be made for all formulas. According to yet another embodiment of the present invention, the software logic under test is described as: if A+B > C and D+E > F, then Path one is executed; if A+B < C and D+E < F, then path two is executed; if a+b=c and d+e=f, path three is performed. When the first path is taken as a target path, the entering conditions are A+B > C and D+E > F, and after the initial value of the parameter A/B/C/D/E/F is obtained, the true or false of the formula is judged: if the A+B > C and the D+E > F are both judged to be true, the parameter value of the parameter A/B/C/D/E/F and the execution result of the execution path I are recorded, and the corresponding position of the test case is filled. If A+B > C and D+E > F have formulas therein that determine false, then the parameter values of the parameters A/B/C/D/E/F need to be adjusted in sequence until both A+B > C and D+E > F are determined to be true.
Specifically, for the parameters in the formulas determined to be false, the values should be selected one by one from left to right, and whether the adjusted parameter values can enable the formulas determined to be false to be more close to the establishment of the determination is determined until all formulas are determined to be established, and at this time, the parameter values and the output result after the target path is executed are recorded and used as the input and expected output result in the test case.
Optionally, the parameter adjustment module includes:
the first processing submodule is used for determining a first formula which is judged to be false in the formulas as a target formula and determining parameter values of various parameters of the target formula;
a parameter adjustment sub-module, configured to adjust each parameter value to make the determination of the target formula 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 all the formulas in the entry condition are judged to be true, and therefore, the formulas judged to be false need to be sequentially adjusted in parameter value until all the formulas are judged to be true.
The parameter value may be adjusted by approaching a trend determined to be true according to the target formula. 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 more approximate to the true judgment, indicating that the adjustment direction is correct, and further increasing the precision on the parameter value to continue judgment; if the target formula is far from the true after adjustment, the adjustment direction is wrong, and the parameter value can be reduced by one precision to continue judgment.
Optionally, the parameter adjustment submodule 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 the judgment of true;
and the second processing unit is used for increasing the parameter value of the first parameter by one precision if the target formula approaches to the judgment of true, and judging whether the target formula approaches to the judgment of true or not until the approaching trend stops or the target formula judges to be true.
The tightening trend is stopped, and if the parameter value of the parameter is adjusted so that the target formula cannot be further approached to the judgment of true, the next parameter is tried to be adjusted until the target formula is judged to be true.
Optionally, the parameter adjustment 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 approaching trend stops, and judging whether the target formula approaches to the true judgment until the approaching trend stops or the target formula judges the true judgment.
Optionally, the parameter adjustment sub-module further includes:
A fourth processing unit, configured to reduce the parameter value of the first parameter by one precision if the target formula is far from the true, and determine whether the target formula approaches the true;
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 the judgment of true, and judging whether the target formula approaches to the judgment of true or not until the approaching trend stops or the target formula judges to be 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 judging and 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, because the software performs the operation periodically, the numerical value calculated by the formula will change along with the change of the calculation period, and the generating device of the test case provided by the embodiment of the invention can make engineers liberated from tedious formula calculation. Specifically, in practical application, the generating device may be integrated in a use case design tool. When the test case is designed according to the calculation type requirement of a formula, a user only needs to fill out various jump conditions (namely the entering conditions) of the tested software and a calculation formula executed after jumping (namely the target path) clearly, set an initial value, execute the target path according to the set times and calculate the input conditions and the expected result of each time.
In the embodiment of the invention, the part of the previous manual calculation is calculated by executing the preset software logic by utilizing the strong calculation capability of the computer, and the loop iteration is automatically performed according to the formula, so that the calculation speed is high, the accuracy is high, the labor and time cost are saved, and the method is more convenient.
The embodiment of the invention also provides a control device which comprises a memory, a processor and a computer program which is stored in the memory and can run on the processor; the processor, when executing the program, implements the generation method as described above.
While the foregoing is directed to the preferred embodiments of the present invention, it will be appreciated by those skilled in the art that various modifications and changes can be made without departing from the principles of the present invention, and such modifications and changes are intended to be within the scope of the present invention.
Claims (7)
1. The method for generating the 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 into the formula;
The obtaining parameter values of a plurality of parameters written into the formula includes: defining initial values and key word indexes of the parameters according to the data types, the precision and the value range obtained from the function description of the tested software;
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, respectively adjusting the parameter value according to each formula judged to be false until the judgment of each formula is true;
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;
the parameter value adjustment is performed for each formula determined to be false, including:
Determining a first formula which is judged to be false in the formulas as a target formula, and determining parameter values of various parameters of the target formula;
adjusting each parameter value to make the judgment of the target formula true;
determining a second formula which is judged to be false in the formulas as a target formula, and respectively adjusting the parameter value for each formula which is judged to be false until the judgment of each formula is true;
Said adjusting each of said parameter values to make the decision of said target formula true comprises:
Increasing the parameter value of the first parameter in the target formula by one precision, and judging whether the target formula approaches to the true value;
if the target formula approaches to true, increasing the parameter value of the first parameter by one precision, and judging whether the target formula approaches to true or not until the approaching trend stops or the target formula is judged to be true;
after the approaching trend stops, the generating method further comprises the following steps:
increasing the parameter value of the next parameter in the target formula by one precision, and judging whether the target formula approaches to the judgment as true or not until the approaching trend stops or the target formula judges as true;
The method for generating the target formula includes the steps of adding a precision to a parameter value of a first parameter in the target formula, judging whether the target formula approaches to the value determined to be true, and further includes:
If the target formula is far from the true, reducing the parameter value of the first parameter by one precision, and judging whether the target formula approaches to the true;
If the target formula approaches to true, reducing the parameter value of the first parameter by one precision, and judging whether the target formula approaches to true or not until the approaching trend stops or the target formula is judged to be true.
2. The generating method according to claim 1, wherein after determining whether or not the determination of each of the formulas is true when determining that each of the parameter values is written into the formulas, the generating 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 or 2, characterized in that after executing the target path, the generation method further comprises:
Acquiring the number of times that the target path needs to be executed;
And 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.
4. A test case generating apparatus, comprising:
The condition acquisition module is used for acquiring the entry condition of the target path of the tested software, wherein 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 obtaining parameter values of a plurality of parameters written into the formula includes: defining initial values and key word indexes of the parameters according to the data types, the precision and the value range obtained from the function description of the tested software;
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 adjustment module is used for respectively adjusting the parameter value for each formula judged to be false if the judgment of at least one formula is false until the judgment of each formula is true;
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;
The parameter adjustment module comprises:
the first processing submodule is used for determining a first formula which is judged to be false in the formulas as a target formula and determining parameter values of various parameters of the target formula;
a parameter adjustment sub-module, configured to adjust each parameter value to make the determination of the target formula true;
the second processing submodule is used for determining a second formula which is judged to be false from a plurality of formulas as a target formula, and respectively adjusting the parameter value for each formula which is judged to be false until the judgment of each formula is true;
the parameter adjustment submodule 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 the judgment of true;
the second processing unit is used for increasing the parameter value of the first parameter by one precision if the target formula approaches to the judgment as true, and judging whether the target formula approaches to the judgment as true or not until the approaching trend stops or the target formula judges as true; the parameter adjustment sub-module further includes:
the third processing unit is used for increasing the parameter value of the next parameter in the target formula by one precision when the approaching trend stops, and judging whether the target formula approaches to true or not until the approaching trend stops or the target formula is judged to be true;
A fourth processing unit, configured to reduce the parameter value of the first parameter by one precision if the target formula is far from the true, and determine whether the target formula approaches the true;
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 the judgment of true, and judging whether the target formula approaches to the judgment of true or not until the approaching trend stops or the target formula judges to be true.
5. The generating apparatus according to claim 4, wherein the generating 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.
6. The generating apparatus according to claim 4 or 5, characterized in that the generating apparatus further comprises:
The frequency acquisition module is used for acquiring the frequency of the target path to be executed;
And the judging and 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.
7. A control device comprising a memory, a processor and a computer program stored on the memory and executable on the processor; a method of generating as claimed in any one of claims 1 to 3, characterized in that the processor when executing the program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010185026.3A CN113407435B (en) | 2020-03-17 | 2020-03-17 | Test case generation method, device and control equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010185026.3A CN113407435B (en) | 2020-03-17 | 2020-03-17 | Test case generation method, device and control equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113407435A CN113407435A (en) | 2021-09-17 |
CN113407435B true CN113407435B (en) | 2024-06-07 |
Family
ID=77677009
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010185026.3A Active CN113407435B (en) | 2020-03-17 | 2020-03-17 | Test case generation method, device and control equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113407435B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2014191652A (en) * | 2013-03-27 | 2014-10-06 | Fujitsu Ltd | Test case generation method, test case generation device, and test case generation program |
CN107818051A (en) * | 2017-11-27 | 2018-03-20 | 北京新能源汽车股份有限公司 | Test case jump analysis method and device and server |
CN108595341A (en) * | 2018-05-11 | 2018-09-28 | 清华大学 | Automatic example generation method and system |
CN108647146A (en) * | 2018-05-11 | 2018-10-12 | 北京信息科技大学 | The method for generating test case of combined covering is judged based on correction conditions |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP6003699B2 (en) * | 2013-02-08 | 2016-10-05 | 富士通株式会社 | Test data generation program, method and apparatus |
-
2020
- 2020-03-17 CN CN202010185026.3A patent/CN113407435B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2014191652A (en) * | 2013-03-27 | 2014-10-06 | Fujitsu Ltd | Test case generation method, test case generation device, and test case generation program |
CN107818051A (en) * | 2017-11-27 | 2018-03-20 | 北京新能源汽车股份有限公司 | Test case jump analysis method and device and server |
CN108595341A (en) * | 2018-05-11 | 2018-09-28 | 清华大学 | Automatic example generation method and system |
CN108647146A (en) * | 2018-05-11 | 2018-10-12 | 北京信息科技大学 | The method for generating test case of combined covering is judged based on correction conditions |
Also Published As
Publication number | Publication date |
---|---|
CN113407435A (en) | 2021-09-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP2960799A1 (en) | Defect localization in software integration tests | |
CN103116540A (en) | Dynamic symbol execution method and device based on global superblock domination graph | |
US20220292229A1 (en) | Material design apparatus, material design method, and material design program | |
KR100919222B1 (en) | The method and apparatus for evaluating performance of test case | |
Sestelo Perez et al. | FWDselect: An R package for variable selection in regression models | |
CN113407435B (en) | Test case generation method, device and control equipment | |
EP3726318B1 (en) | Computer-implemented determination of a quality indicator of a production batch-run that is ongoing | |
Huang et al. | Dissimilarity‐based test case prioritization through data fusion | |
CN108761310B (en) | Quantum chip test method | |
CN109783837A (en) | Emulator, analogue system, emulation mode and simulated program | |
US20070094540A1 (en) | Program analysis program, program analysis device, and program analysis method | |
Jaffar et al. | Optimal MC/DC test case generation | |
CN114757166A (en) | Evaluation method and device of natural language understanding system and network equipment | |
CN109614999A (en) | Data processing method, device, equipment and computer readable storage medium | |
CN113688403A (en) | Intelligent contract vulnerability detection method and device based on symbolic execution verification | |
CN114799561A (en) | Laser cutting process parameter optimization method based on case reasoning and model reasoning | |
Ernst et al. | Time-staging enhancement of hybrid system falsification | |
EP3726317B1 (en) | Computer-implemented determination of a quality indicator of a production batch-run of a production process | |
CN113569252A (en) | Vulnerability detection method based on function and branch coverage by combining neural network | |
US9811373B2 (en) | Analysis engine control device | |
CN117471504B (en) | GNSS baseband chip verification method, electronic equipment and medium | |
US20230273925A1 (en) | Method and apparatus for database management system query planning | |
CN111290946A (en) | Floating point number error detection method and device based on atomic state function | |
Mittas et al. | StatREC: A graphical user interface tool for visual hypothesis testing of cost prediction models | |
Brown et al. | Technical manual for QMPE v2. 18: Fortran code to fit response time distributions |
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 | ||
GR01 | Patent grant |