CN104317708A - Software testing case automatic generating method and system based on iterative interval arithmetic - Google Patents
Software testing case automatic generating method and system based on iterative interval arithmetic Download PDFInfo
- Publication number
- CN104317708A CN104317708A CN201410562727.9A CN201410562727A CN104317708A CN 104317708 A CN104317708 A CN 104317708A CN 201410562727 A CN201410562727 A CN 201410562727A CN 104317708 A CN104317708 A CN 104317708A
- Authority
- CN
- China
- Prior art keywords
- interval
- variable
- current
- arithmetic
- value
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 52
- 238000013522 software testing Methods 0.000 title abstract description 3
- 238000012360 testing method Methods 0.000 claims abstract description 77
- 230000007246 mechanism Effects 0.000 claims abstract description 8
- 238000005516 engineering process Methods 0.000 claims description 23
- 230000008569 process Effects 0.000 claims description 18
- 230000008094 contradictory effect Effects 0.000 claims description 7
- 230000008676 import Effects 0.000 claims description 3
- 238000010586 diagram Methods 0.000 abstract description 5
- 230000001276 controlling effect Effects 0.000 description 40
- 238000002474 experimental method Methods 0.000 description 5
- 238000004458 analytical method Methods 0.000 description 4
- 230000006870 function Effects 0.000 description 4
- 238000012804 iterative process Methods 0.000 description 3
- 230000006835 compression Effects 0.000 description 2
- 238000007906 compression Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 239000000284 extract Substances 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000013459 approach Methods 0.000 description 1
- 230000015572 biosynthetic process Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000002596 correlated effect Effects 0.000 description 1
- 230000000875 corresponding effect Effects 0.000 description 1
- 230000003247 decreasing effect Effects 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 239000000203 mixture Substances 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000012552 review Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000010998 test method Methods 0.000 description 1
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The invention relates to a software testing case automatic generating method and system based on iterative interval arithmetic. The method includes the steps of S1, reading the preset path of a to-be-tested program, and traversing the control flow diagram of the to-be-tested program to obtain the value interval of each variable of the preset path; S2, using the value interval of each variable to traverse the control flow diagram through the iterative interval arithmetic to obtain the initial stable variable value interval of each variable; S3, initializing the infinite variable value interval in the initial stable value interval, traversing the control flow diagram through the iterative interval arithmetic, and saving the operation result into the initial stable variable value interval; S4, sorting the variables according to a preset mechanism, and determining a current variable; S5, performing rollback operation, iterative interval arithmetic and backtrack operation on the initial stable variable value interval of the current variable to generate a testing case; S6, verifying the generated testing case.
Description
Technical field
The present invention relates to software testing technology, particularly relate to a kind of software test case automatic generating method and system of the interval arithmetic based on iteration.
Background technology
Software test is before software puts into operation, to the final review of software requirement analysis, design specification and coding, is the committed step of software quality assurance.Statistics shows, the expense of software test and maintenance is account for whole software R & Dcost more than 50%.In software test, many method of testings contain a large amount of manual operations, and irksome and easily make mistakes when these operate in manual completing, What is more, calculate by hand beyond problem scope or be completely impracticable in manual methods.In order to reduce the cost of manual testing and improve the reliability of testing, researchist is devoted to realize test automation always, and one of them important activity is exactly automatic generating test use case.
In numerous method for testing software, the Test cases technology problem (referred to as problem Q) of path-oriented can be described as: any paths W in a given program or program module P and P, variable xi if there is in an input statement of program module P or an input parameter of P, then claims xi to be the input variable of P.The field of definition Dxi of input variable xi is all possible value set of xi.An input vector x={x1, x2 ..., xm} ∈ (Dx1 × Dx2 × ... × Dxm) be called that a program of program module P inputs, referred to as an input of P, wherein m is the number of input variable in P.If all input data tables of P show for solution space D, ask x ∈ D, its target is at the end of test, and make to take x as input working procedure module P, program is run along path W.Research shows, for arbitrary P and W, there is not general efficient algorithm and solves x, and cannot ensure that W must be reachable path, needs to judge the accessibility of W in generating test use case process.The Test cases technology of current path W, mainly by manually having come, needs a large amount of time.Under many circumstances, if path W more complicated, such as, the branching ratio comprised is more, or branch's more complicated, and artificial generating test use case is almost unlikely.
Be engaged in both at home and abroad in the enterprise of software test at present, mostly adopting manual type or computer-assisted way generating case.The shortcoming of these two kinds of generating test use case methods is: 1) generating case requires a great deal of time, and testing efficiency is low; 2) need the software test personnel of specialty, and need these personnel very familiar to tested software; 3) effect is tested with a low credibility.
Summary of the invention
The invention provides a kind of software test case automatic generating method and system of the interval arithmetic based on iteration, can according to the controlling stream graph of given software under testing program, generate satisfactory test case for specified path, improve efficiency and the automaticity of software test.Iterative processing is carried out to the interval arithmetic in Test cases technology process, to reach the object of infeasible paths detection and variable-value interval narrowing simultaneously.
According to above-mentioned purpose, the invention provides a kind of software test case automatic generating method of the interval arithmetic based on iteration, described method comprises:
S1, the predefined paths read in program to be measured, the variable-value being obtained each variable of described predefined paths by the controlling stream graph traveling through described program to be measured is interval;
S2, described variable-value interval is traveled through described controlling stream graph by the interval arithmetic of iteration, the incipient stability variable-value obtaining variable described in each is interval;
S3, initialization process is carried out to the infinitely variable interval in described incipient stability variable-value interval, travel through described controlling stream graph by the interval arithmetic of iteration, and it is interval operation result to be saved in described incipient stability variable-value;
The mechanism that S4, basis are preset sorts to variable, and determines current variable;
S5, the incipient stability variable-value of described current variable interval carried out to rollback computing, the interval arithmetic of iteration and trace-back operation, generating test use case;
S6, to generate described test case verify.
Wherein, described step S2 specifically comprises:
S21, the variable-value of variable described in each and correspondence interval being imported into the Ingress node of described controlling stream graph, carrying out interval arithmetic by traveling through described controlling stream graph;
S22, when the current interval computing of arbitrary described variable conflicts, then decision paths is unreachable, terminates described current interval computing;
S23, current interval computing not contradiction when all described variablees, judge that whether current interval operation result is identical with the result of last interval arithmetic;
If the current interval operation result of the arbitrary described variable of S24 is different with described last interval arithmetic result, judge whether the result of the current interval computing of arbitrary described variable has than the result of described last interval arithmetic to reduce, reduce if having, the current interval operation result of all described variablees is set to new initial conditions, return step S21 and proceed interval arithmetic, if do not reduce, terminate current interval computing;
If current interval operation result and the described last interval arithmetic of all described variablees of S25 come to the same thing, then the current variable interval of variable described in each carried out compressing and be saved in the incipient stability variable-value interval of each variable described.
Wherein, described step S3 specifically comprises:
S31, the infinitely variable interval in the incipient stability variable-value interval of variable described in each to be compressed according to interval initialization strategy, form the bounded variable interval of variable described in each;
S32, the bounded variable interval of variable described in each and correspondence being passed to the Ingress node of described controlling stream graph, carrying out interval arithmetic by traveling through described controlling stream graph;
S33, when the current interval computing of arbitrary described variable conflicts, the border of the bounded variable interval conflicted is amplified, then re-executes step S32;
S34, current interval computing not contradiction when all described variablees, judge that whether current interval operation result is identical with the result of last interval arithmetic;
If the current interval operation result of the arbitrary described variable of S35 is different with described last interval arithmetic result, judge whether the result of the current interval computing of arbitrary described variable has than the result of described last interval arithmetic to reduce, reduce if having, the current interval operation result of all described variablees is set to new initial conditions, return step S32 and proceed interval arithmetic, if do not reduce, terminate current interval computing;
If current interval operation result and the last interval arithmetic of all described variablees of S36 come to the same thing, then the current interval computing of variable described in each compressed and be saved in described incipient stability variable-value interval.
Wherein, described step S5 specifically comprises:
S51, be that described current variable selects rollback value;
S52, imports the Ingress node of described controlling stream graph into by described rollback value, carry out interval arithmetic by traveling through described controlling stream graph;
S53, judge whether current interval computing conflicts, occur then to carry out step S54, otherwise perform step S56;
S54, choose next rollback value according to contradictory information, then perform step S52 and judge whether to conflict, when the interval arithmetic of all rollback values of described current variable all conflicts, perform step S55;
S55, current variable to be recalled, then again choose rollback value for described current variable, and perform step S52, when the interval arithmetic of all rollback values of the described current variable after recalling all conflicts, terminate computing;
S56, when interval arithmetic not contradiction, judge that whether current interval operation result is identical with the result of last interval arithmetic;
If the current interval operation result of the arbitrary described variable of S57 is different with described last interval arithmetic result, judge whether the result of the current interval computing of arbitrary described variable has than the result of described last interval arithmetic to reduce, reduce if having, the current interval operation result of all described variablees is set to new initial conditions, return step S52 and proceed interval arithmetic, if do not reduce, terminate current interval computing;
If current interval operation result and the last interval arithmetic of all described variablees of S58 come to the same thing, then the incipient stability variable-value interval of current variable is saved in stable variable-value interval, generating test use case.
Wherein, step S6 comprises:
S61, drive described program to be measured by the test case of described generation, and according to the path of the actual execution of the code record of plug-in mounting;
The path of S62, actual execution and preset path, judge whether the path of actual execution and preset path meet, if do not met, and described Test cases technology failure; If met, then the test case obtained stored and returned to user.
According to another aspect of the present invention, provide a kind of software test case automatic creation system of the interval arithmetic based on iteration, described system comprises:
Pretreatment module, for reading the predefined paths in program to be measured, the variable-value being obtained each variable of described predefined paths by the controlling stream graph traveling through described program to be measured is interval;
Computing module between original area, for described variable-value interval is traveled through described controlling stream graph by the interval arithmetic of iteration, the incipient stability variable-value obtaining variable described in each is interval;
Infinitely variable interval arithmetic module, for carrying out initialization process to the infinitely variable interval in described incipient stability variable-value interval, travel through described controlling stream graph by the interval arithmetic of iteration, and it is interval described operation result to be saved in described incipient stability variable-value;
Order module, for sorting to variable according to the mechanism preset, and determines current variable;
Test cases technology module, for carrying out rollback computing, the interval arithmetic of iteration and trace-back operation, generating test use case to the incipient stability variable-value of described current variable interval;
Authentication module, for verifying the described test case generated.
Wherein, between described original area, computing module comprises:
Input block, for importing the Ingress node of described controlling stream graph into by the variable-value of each variable and correspondence interval;
Arithmetic element, for carrying out interval arithmetic by interval for the variable-value of each variable described in input by the described controlling stream graph of traversal;
Judging unit, for judging whether the current interval computing of arbitrary variable conflicts, when conflicting, terminates current interval computing, when not contradiction, judged result is input to described updating block;
Updating block, for current operation result and last operation result are compared, reduce if current interval operation result has than described last interval arithmetic result, then current interval operation result is set to new initial conditions, is input to interval arithmetic unit and proceeds interval arithmetic;
Storage unit, current variable interval during for current interval operation result described in described judging unit and described last interval arithmetic being come to the same thing carries out compressing and is saved in incipient stability variable-value interval.
Wherein, described Test cases technology module comprises:
Assignment unit, for selecting rollback value for described current variable;
Current variable interval arithmetic element, for importing described rollback value into Ingress node condition, carries out interval arithmetic by traveling through described controlling stream graph;
Interval arithmetic judging unit, for judging whether current interval computing conflicts, when current interval computing conflicts, according to contradictory information choose next rollback value or backtracking after again for current variable chooses rollback value, and re-start interval arithmetic, if again without forerunner's variable, then branch and bound failure, Test cases technology failure;
Comparing unit, for current interval computing not contradiction time, the result of current interval operation result and last interval arithmetic is compared, if the result of current interval computing is less than the result of described last interval arithmetic, then current interval operation result is set to new initial conditions, is input to current variable interval arithmetic element and proceeds interval arithmetic;
Test case storage unit, current variable interval during for current interval operation result described in described judging unit and described last interval arithmetic being come to the same thing carries out compressing and is saved in incipient stability infinitely variable interval, generating test use case.
The software test case automatic generating method of the interval arithmetic based on iteration of the present invention and system, owing to have employed the interval arithmetic technology of iteration, when each path analysis can farthest refinement to arrive fixed point, so path accessibility judgement can be carried out before use-case generation starts, if path can reach, obtain satisfactory test case set according to the search of given software under testing program element exactly, the present invention simultaneously also can verify the test case generated, improve the accuracy of test case, substantially increase efficiency and the automaticity of software test.
Accompanying drawing explanation
Can understanding the features and advantages of the present invention clearly by reference to accompanying drawing, accompanying drawing is schematic and should not be construed as and carry out any restriction to the present invention, in the accompanying drawings:
Fig. 1 shows the process flow diagram of the software test case automatic generating method of the interval arithmetic based on iteration of the present invention.
Fig. 2 shows the particular flow sheet of the step S2 of software test case automatic generating method of the present invention.
Fig. 3 shows the particular flow sheet of the step S3 of software test case automatic generating method of the present invention.
Fig. 4 shows the particular flow sheet of the step S5 of software test case automatic generating method of the present invention.
Fig. 5 shows the structured flowchart of software test case automatic creation system of the present invention.
Embodiment
Below in conjunction with accompanying drawing, embodiments of the present invention is described in detail.
The software test case automatic generating method of the interval arithmetic based on iteration of the present invention, its basic thought is: first read the given path in software under testing source program, pre-service is carried out by traversal controlling stream graph, comprise expression formula to extract, obtain variable levels and correlated variables closure collection, initializing variable property list, thus node each variable-value in acquisition approach end is interval; Then, whether can be reached by iteration traversal controlling stream graph decision paths, and input interval is compressed; Then, whether can be reached by iteration traversal controlling stream graph decision paths for infinite border, and input interval is compressed; Then, by decision-making mechanism, variable is sorted, and by rollback computing, subsume and trace-back operation, generating test use case; Finally, drive and perform tested program, the actual execution route of the above-mentioned program element provided and destination path are compared, check whether gained test case meets required path.
In the present embodiment, abstract syntax tree and the control flow check map generalization of abstract program to be measured belong to prior art, simple in order to describe, and no longer describe in the present embodiment.
Abstract syntax tree comprises the object and symbol table that represent type information, and they are connected into tree structure, this is the most basic output of compiler front-end, and abstract syntax tree comprises all relevant informations obtained from source code, and can embody the syntactic structure of source program completely.Above-mentioned abstract syntax tree has consistent tactic pattern, is made up of dissimilar node, and each category node is all described as a class formation.All syntax tree nodes all support a unified visitor interface, so just can carry out further multi-form processing, traversal access and output to abstract syntax tree by visitor easily.
A program control flowchart can be expressed as (N, E, Entry, Exit).Wherein, N represents the set of node, the statement in reflection program and condition judgment; E represents the set of directed edge, the control flow check relation in reflection program between statement; Entry is the sole inlet node that program is fixed; Exit be program unique exit node.Briefly: controlling stream graph is exactly the digraph with single, fixing entry node and outlet node.
Fig. 1 shows the process flow diagram of the software test case automatic generating method of the interval arithmetic based on iteration of the present invention.
With reference to Fig. 1, software test case automatic generating method of the present invention comprises step:
S1, the predefined paths read in program to be measured, the variable-value being obtained each variable of described predefined paths by the controlling stream graph traveling through described program to be measured is interval.
Particularly, step S1 comprises:
Step S11, by traversal controlling stream graph, extract containing the node of expression formula, and be stored in linear tabular.
Each node in the linear list of step 12, traversal step S11, extracts variable and expression formula.
By each node in traversal linear list, expression formula in conditional statement and variable are extracted, wherein, expression formula is used for the calculating of condition, and variable is as the operand of subsequent searches process.This process is carried out along the path that step S11 provides, and also will consider the assignment statement on path in process.Some condition can determine the value of certain or some variablees uniquely.And these implicit values are just as assignment, no longer need further search.This can reduce search volume greatly.To preferentially calculate this condition;
Such as, conditional statement: if (a==3) ..., now, the valued space of variable a can only be just { 3};
Above-mentioned preferential calculating can the derivative search principle of the strategy of condition of unique determined value be limited area first search: some variable is initial or through some constraint, region of search is become and only has limited several point, this variable of first search contributes to finding contradiction as early as possible or searching for successfully under these conditions.
Such as, suppose that x is an integer variable, if (1≤x≤3) ..., this condition determines x ∈ [1,2,3].
Step S13, try to achieve each input variable interval of end, path node.
Original input variable generally includes the global variable and static variable used in function parameter, function, first by ergodic abstract syntax tree, identifies these variablees.The interval of variable is determined according to type corresponding in the language of tested program and operating system environment usually.The form of variable-value section definition is:
(x1, Dx1), (x2, Dx2) ..., wherein x represents variable name, and D represents its interval.
S2, described variable-value interval is traveled through described controlling stream graph by the interval arithmetic of iteration, the incipient stability variable-value obtaining variable described in each is interval.
Fig. 2 shows the particular flow sheet of the step S2 of Generation of software test case method of the present invention.
With reference to Fig. 2, step S2 specifically comprises:
S21, the variable-value of variable described in each and correspondence interval being imported into the Ingress node of described controlling stream graph, carrying out interval arithmetic by traveling through described controlling stream graph;
S22, when the current interval computing of arbitrary described variable conflicts, then decision paths is unreachable, terminates described current interval computing;
S23, current interval computing not contradiction when all described variablees, then compare with the result of last interval arithmetic, judge that whether current interval operation result is identical with the result of last interval arithmetic;
If the current interval operation result of the arbitrary described variable of S24 is different with described last interval arithmetic result, judge whether the result of the current interval computing of arbitrary described variable has than the result of described last interval arithmetic to reduce, reduce if having, the current interval operation result of all described variablees is set to new initial conditions, return step S21 and proceed interval arithmetic, if do not reduce, terminate current interval computing;
If current interval operation result and the described last interval arithmetic of all described variablees of S25 come to the same thing, then the current variable interval of variable described in each carried out compressing and be saved in the incipient stability variable-value interval of each variable described.
In the present embodiment, infeasible paths refers in given input interval, and this path may be performed never.
Analysis shows, there is a large amount of infeasible paths in general program.In the process producing test case, select infeasible paths to be possible, this is also one of principal element affecting testing efficiency, therefore should stop the calculating to this path as early as possible, exit Test cases technology module.
Such as:
In the above example, node each input variable interval in end, path is { (a, [1 ,+inf]), (b, [-inf ,-5]) }, can find out that this interval does not meet first condition in path; In fact in program, three if conditions get the path of branch's composition of true value is exactly an infeasible paths, because these conditions of b>a, b<-4 and a>0 are contradiction.
Step S2 is with { (a, [1, + inf]), (b, [-inf ,-5]) } again controlling stream graph is traveled through as input, then just conflict at first Nodes, thus determine infeasible paths, finish the implementation of algorithm in advance, avoid unnecessary work below.
For non-infeasible paths, then according to the assignment in the field of definition of original input variable, program and conditional statement, carry out space compression from top to bottom, the result of compression is: (x1, D ' x1), and (x2, D ' x2) ...;
The field of definition of original input variable is determined by type of variables and operating system environment, and the assignment in calculation procedure and the limited range of conditional statement, compress further to the valued space of original input variable.
Such as:
In the above example, node each input variable interval in end, path is { (a, [-inf, + inf]), (b, [1 ,+inf]) }, this interval can be found out and not exclusively meet first condition in path, having a lot of work be wasted in those intervals of the b<a that do not satisfy condition if carry out follow-up computing with this interval for input; And the interval arithmetic of iteration is carried out using the interval of this end, path node as input, the variable-value interval obtaining each node after iteration is stablized is:
S3, initialization process is carried out to the infinitely variable interval in described incipient stability variable-value interval, travel through described controlling stream graph by the interval arithmetic of iteration, and it is interval operation result to be saved in described incipient stability variable-value;
Fig. 3 shows the particular flow sheet of the step S3 of Generation of software test case method of the present invention.
With reference to Fig. 3, step S3 specifically comprises:
S31, the infinitely variable interval in the incipient stability variable-value interval of variable described in each to be compressed according to interval initialization strategy, form the bounded variable interval of variable described in each.
The variable-value interval that step S2 exports sometimes has [a, + inf], [-inf, b], [-inf, + inf] such infinite border, in the interval of such unbounded for variable finds test case and make it ensure can to reach its workload very huge in path, the absolute value of its test case generated is often very huge, is unfavorable for understanding and the checking of user.So there are above three kinds of situations in the interval for variable, then turned to the interval of bounded according to certain principle.
S32, the bounded variable interval of variable described in each and correspondence being passed to the Ingress node of described controlling stream graph, carrying out interval arithmetic by traveling through described controlling stream graph;
S33, when the current interval computing of arbitrary described variable conflicts, illustrate that interval initialization strategy causes efficient solution to be excluded outside between original area, then the border of the bounded variable interval conflicted is amplified, then re-execute step S32.
S34, current interval computing not contradiction when all described variablees, then compare with the result of last interval arithmetic, judge that whether current interval operation result is identical with the result of last interval arithmetic.
An interval arithmetic from the inlet to the outlet in individual paths, as function, it is monotone decreasing.Therefore can prove, this function can be stabilized to a fixed point (empty set can regard a kind of special circumstances as, and it is the infimum of Interval Set) by iteration.Therefore, after each interval arithmetic terminates, all need to contrast with the result of last interval arithmetic, check whether that iteration is stablized.
If the current interval operation result of the arbitrary described variable of S35 is different with described last interval arithmetic result, judge whether the result of the current interval computing of arbitrary described variable has than the result of described last interval arithmetic to reduce, reduce if having, the current interval operation result of all described variablees is set to new initial conditions, return step S32 and proceed interval arithmetic, if do not reduce, terminate current interval computing.
If current interval operation result and the last interval arithmetic of all described variablees of S36 come to the same thing, then the current interval computing of variable described in each compressed and be saved in described incipient stability variable-value interval.
The mechanism that S4, basis are preset sorts to variable, and determines current variable.
S5, the incipient stability variable-value of described current variable interval carried out to rollback computing, the interval arithmetic of iteration and trace-back operation, generating test use case.
Fig. 4 shows the particular flow sheet of the step S5 of Generation of software test case method of the present invention.
With reference to Fig. 4, step S5 specifically comprises:
S51, be that described current variable selects rollback value.
S52, described rollback value being imported into the Ingress node of described controlling stream graph, carrying out interval arithmetic by traveling through described controlling stream graph.
For current variable selects rollback value, now the interval shape of current variable is as [V, V], namely the range format that bound is equal is expressed as, and the interval of its dependent variable (rollback and non-rollback) remains unchanged, the interval of what the interval that namely distance last iteration is stable uniquely changed is exactly current variable becomes a determined value from a bounded interval.In this bounded interval, comprise efficient solution, otherwise the interval arithmetic of last iteration can judge contradiction.Therefore, the efficient solution of this selected rollback value whether in this interval need only be judged.Thus, import the interval (interval of current variable is determined value) of Ingress node condition and all variablees into, carry out interval arithmetic by traversal controlling stream graph.
S53, judge whether current interval computing conflicts, conflict, selected by determination step S51 is not efficient solution in current variable interval, therefore need to choose next rollback value according to contradictory information, namely then carry out step S54, otherwise perform step S56;
S54, choose next rollback value according to contradictory information, judge whether to conflict according to step S52, when the interval arithmetic of all rollback values of described current variable all conflicts, perform step S55;
S55, current variable to be recalled, then again choose rollback value for described current variable, and perform step S52, when the interval arithmetic of all rollback values of the described current variable after recalling all conflicts, terminate computing;
S56, when interval arithmetic not contradiction, interval arithmetic result and last round of interval arithmetic result to be compared, judge that whether current interval operation result is identical with the result of last interval arithmetic;
If the current interval operation result of the arbitrary described variable of S57 is different with described last interval arithmetic result, judge whether the result of the current interval computing of arbitrary described variable has than the result of described last interval arithmetic to reduce, reduce if having, the current interval operation result of all described variablees is set to new initial conditions, return step S52 and proceed interval arithmetic, if do not reduce, terminate current interval computing.
If the current interval operation result of the current all variablees of S58 is identical with last operation result, then the incipient stability variable-value interval of current variable is saved in stable variable-value interval, generating test use case.
S6, to generate described test case verify.
Step S6 comprises:
S61, the code that plug-in mounting is extra in program to be measured, to obtain the information of program to be measured behavior when performing;
Extra code is inserted, to obtain the information of program behavior when being performed in tested software program; Above-mentioned extra code can be statement.Plug-in mounting mainly determines plug-in mounting point according to controlling stream graph, implements plug-in mounting in the beginning of tested program controlling stream graph, bifurcation to tested program, then generates the plug-in mounting statement tree node on abstract syntax tree, then abstract syntax tree is changed again that to export be source program.
Such as, follow procedure:
After automatic plug-in mounting shape as:
In the process performing tested program, just can the routing information of the actual execution of collection procedure.
S62, drive described program to be measured by the test case of described generation, and according to the path of the actual execution of the code record of plug-in mounting;
The path of S63, actual execution and preset path, judge whether the path of actual execution and preset path meet, if do not met, and described Test cases technology failure; If met, then the test case obtained stored and returned to user.
The actual execution route of plug-in mounting code record above, itself and destination path are contrasted, if do not met (namely not identical), illustrate that the test case obtained can not cover path to be measured, will regenerate, this causes because some in Test cases technology process simplify approximate treatment.
It is below specific embodiment.
Example 1: the degree that the interval arithmetic of the main iteration of experiment of this part is supported larger program, wherein tested program divides number to reach 601, and variable number is 50.
The interval arithmetic contrast experiment tested program of table 1 iteration is introduced
Interval arithmetic contrast and experiment (the A: the interval arithmetic adopting iteration of table 2 iteration; B: the interval arithmetic not adopting iteration)
From above result, interval iterative process can judge some infeasible paths.An infeasible paths is had to be judged by iterative process in this example.After eliminating this paths, branch and bound can be other 13 whole generating test use cases of reachable path.For the path of constraint more complicated, cannot solve through interval iterative process, in this experiment, 2 in 14 paths reach path and only have the process through iteration could generating test use case.
Example 2: the experiment of this part is mainly tested this Test cases technology system and can be supported how many expression formulas: the interval arithmetic adopting iteration, progressively increase variable number and expression formula number are tested, and test can process at most how many variablees and expression formula.Experimental result is as shown in table 3.As can be seen from Table 3, be the tested program of 50 to 601 for a point number, current system can generate the test case that 100% statement covers.
Table 3 logarithm value type program test use-case generates result
Result is from the above mentioned known, because software test case automatic creation system of the present invention have employed the interval arithmetic technology of iteration, so satisfactory test case set can be obtained according to the search of given software under testing program element exactly, and the anticipation of infeasible paths can be carried out, greatly improving efficiency and the automaticity of software test, is preferably based on the method for generating test case in path.
In an alternative embodiment of the invention, provide a kind of software test case automatic creation system of the interval arithmetic based on iteration.
Fig. 5 shows the structured flowchart of software test case automatic creation system of the present invention.
With reference to Fig. 5, this system comprises:
Pretreatment module 10, for reading the predefined paths in program to be measured, the variable-value being obtained each variable of described predefined paths by the controlling stream graph traveling through described program to be measured is interval;
Computing module 20 between original area, for described variable-value interval is traveled through described controlling stream graph by the interval arithmetic of iteration, the incipient stability variable-value obtaining variable described in each is interval;
Infinitely variable interval arithmetic module 30, for carrying out initialization process to the infinitely variable interval in described incipient stability variable-value interval, travel through described controlling stream graph by the interval arithmetic of iteration, and it is interval described operation result to be saved in described incipient stability variable-value;
Order module 40, for sorting to variable according to the mechanism preset, and determines current variable;
Test cases technology module 50, for carrying out rollback computing, the interval arithmetic of iteration and trace-back operation, generating test use case to the incipient stability variable-value of described current variable interval;
Authentication module 60, for verifying the described test case generated.
Wherein, between original area, computing module 20 comprises:
Input block 201, for importing the Ingress node of described controlling stream graph into by the variable-value of each variable and correspondence interval;
Arithmetic element 202, for carrying out interval arithmetic by interval for the variable-value of each variable described in input by the described controlling stream graph of traversal;
Judging unit 203, for judging whether the current interval computing of arbitrary variable conflicts, and terminates current interval computing when conflicting, is input to described updating block when not contradiction by judged result;
Updating block 204, for current operation result and last operation result are compared, reduce if current interval operation result has than described last interval arithmetic result, then current interval operation result is set to new initial conditions, is input to interval arithmetic unit and proceeds interval arithmetic;
Storage unit 205, current variable interval during for current interval operation result described in described judging unit and described last interval arithmetic being come to the same thing carries out compressing and is saved in incipient stability variable-value interval.
Wherein, Test cases technology module 40 comprises:
Assignment unit 401, for selecting rollback value for described current variable;
Current variable interval arithmetic element 402, for importing described rollback value into Ingress node condition, carries out interval arithmetic by traveling through described controlling stream graph;
Interval arithmetic judging unit 403, for judging whether current interval computing conflicts, when conflicting according to contradictory information choose next rollback value or backtracking after again for current variable chooses rollback value, and re-start interval arithmetic, if again without forerunner's variable, then branch and bound failure, Test cases technology failure;
Judge updating block 404, for current interval computing not contradiction time, the result of current interval operation result and last interval arithmetic is compared, if the result of current interval computing is less than the result of described last interval arithmetic, then current interval operation result is set to new initial conditions, is input to current variable interval arithmetic element and proceeds interval arithmetic;
Test case storage unit 405, current variable interval during for current interval operation result described in described judging unit and described last interval arithmetic being come to the same thing carries out compressing and is saved in incipient stability infinitely variable interval, generating test use case
The software test case automatic generating method of the interval arithmetic based on iteration of the present invention and system, owing to have employed the interval arithmetic technology of iteration, when each path analysis can farthest refinement to arrive fixed point, so path accessibility judgement can be carried out before use-case generation starts, if path can reach, obtain satisfactory test case set according to the search of given software under testing program element exactly, the present invention simultaneously also can verify the test case generated, improve the accuracy of test case, substantially increase efficiency and the automaticity of software test.
Although describe embodiments of the present invention by reference to the accompanying drawings, but those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present invention, such amendment and modification all fall into by within claims limited range.
Claims (8)
1. based on the software test case automatic generating method of the interval arithmetic of iteration, it is characterized in that, described method comprises:
S1, the predefined paths read in program to be measured, the variable-value being obtained each variable of described predefined paths by the controlling stream graph traveling through described program to be measured is interval;
S2, described variable-value interval is traveled through described controlling stream graph by the interval arithmetic of iteration, the incipient stability variable-value obtaining variable described in each is interval;
S3, initialization process is carried out to the infinitely variable interval in described incipient stability variable-value interval, obtain bounded variable interval, and described bounded variable interval is traveled through described controlling stream graph by the interval arithmetic of iteration, and it is interval operation result to be saved in described incipient stability variable-value;
The mechanism that S4, basis are preset sorts to variable, and determines current variable;
S5, the incipient stability variable-value of described current variable interval carried out to rollback computing, the interval arithmetic of iteration and trace-back operation, generating test use case;
S6, to generate described test case verify.
2. software test case automatic generating method according to claim 1, is characterized in that, described step S2 specifically comprises:
S21, the variable-value of variable described in each and correspondence interval being imported into the Ingress node of described controlling stream graph, carrying out interval arithmetic by traveling through described controlling stream graph;
S22, when the current interval computing of arbitrary described variable conflicts, then decision paths is unreachable, terminates described current interval computing;
S23, current interval computing not contradiction when all described variablees, judge that whether current interval operation result is identical with the result of last interval arithmetic;
If the current interval operation result of the arbitrary described variable of S24 is different with described last interval arithmetic result, judge whether the result of the current interval computing of arbitrary described variable has compared with the result of described last interval arithmetic to reduce, reduce if having, the current interval operation result of all described variablees is set to new initial conditions, return step S21 and proceed interval arithmetic, if do not reduce, terminate current interval computing;
If current interval operation result and the described last interval arithmetic of all described variablees of S25 come to the same thing, then the current variable interval of variable described in each carried out compressing and be saved in the incipient stability variable-value interval of each variable described.
3. software test case automatic generating method according to claim 1, is characterized in that, described step S3 specifically comprises:
S31, the infinitely variable interval in the incipient stability variable-value interval of variable described in each to be compressed according to interval initialization strategy, form the bounded variable interval of variable described in each;
S32, the bounded variable interval of variable described in each and correspondence being passed to the Ingress node of described controlling stream graph, carrying out interval arithmetic by traveling through described controlling stream graph;
S33, when the current interval computing of arbitrary described variable conflicts, the border of the bounded variable interval conflicted is amplified, then re-executes step S32;
S34, current interval computing not contradiction when all described variablees, judge that whether current interval operation result is identical with the result of last interval arithmetic;
If the current interval operation result of the arbitrary described variable of S35 is different with described last interval arithmetic result, judge whether the result of the current interval computing of arbitrary described variable has than the result of described last interval arithmetic to reduce, reduce if having, the current interval operation result of all described variablees is set to new initial conditions, return step S32 and proceed interval arithmetic, if do not reduce, terminate current interval computing;
If current interval operation result and the last interval arithmetic of all described variablees of S36 come to the same thing, then the current interval computing of variable described in each compressed and be saved in described incipient stability variable-value interval.
4. software test case automatic generating method according to claim 1, is characterized in that, described step S5 specifically comprises:
S51, be that described current variable selects rollback value;
S52, imports the Ingress node of described controlling stream graph into by described rollback value, carry out interval arithmetic by traveling through described controlling stream graph;
S53, judge whether current interval computing conflicts, occur then to carry out step S54, otherwise perform step S56;
S54, choose next rollback value according to contradictory information, then perform step S52 and judge whether to conflict, when the interval arithmetic of all rollback values of described current variable all conflicts, perform step S55;
S55, current variable to be recalled, then again choose rollback value for described current variable, and perform step S52, when the interval arithmetic of all rollback values of the described current variable after recalling all conflicts, terminate computing;
S56, when interval arithmetic not contradiction, judge that whether current interval operation result is identical with the result of last interval arithmetic;
If the current interval operation result of the arbitrary described variable of S57 is different with described last interval arithmetic result, judge whether the result of the current interval computing of arbitrary described variable has than the result of described last interval arithmetic to reduce, reduce if having, the current interval operation result of all described variablees is set to new initial conditions, return step S52 and proceed interval arithmetic, if do not reduce, terminate current interval computing;
If current interval operation result and the last interval arithmetic of all described variablees of S58 come to the same thing, then the incipient stability variable-value interval of current variable is saved in stable variable-value interval, generating test use case.
5. software test case automatic generating method according to claim 1, is characterized in that, described step S6 comprises:
S61, the code that plug-in mounting is extra in program to be measured, to obtain the information of program to be measured behavior when performing;
S62, drive described program to be measured by the test case of described generation, and according to the path of the actual execution of the code record of plug-in mounting;
The path of S63, actual execution and preset path, judge whether the path of actual execution and preset path meet, if do not met, and described Test cases technology failure; If met, then the test case obtained stored and returned to user.
6. based on the software test case automatic creation system of the interval arithmetic of iteration, it is characterized in that, described system comprises:
Pretreatment module, for reading the predefined paths in program to be measured, the variable-value being obtained each variable of described predefined paths by the controlling stream graph traveling through described program to be measured is interval;
Computing module between original area, for described variable-value interval is traveled through described controlling stream graph by the interval arithmetic of iteration, the incipient stability variable-value obtaining variable described in each is interval;
Infinitely variable interval arithmetic module, for carrying out initialization process to the infinitely variable interval in described incipient stability variable-value interval, travel through described controlling stream graph by the interval arithmetic of iteration, and it is interval described operation result to be saved in described incipient stability variable-value;
Order module, for sorting to variable according to the mechanism preset, and determines current variable;
Test cases technology module, for carrying out rollback computing, the interval arithmetic of iteration and trace-back operation, generating test use case to the incipient stability variable-value of described current variable interval;
Authentication module, for verifying the described test case generated.
7. software test case automatic creation system according to claim 6, is characterized in that, between described original area, computing module comprises:
Input block, for importing the Ingress node of described controlling stream graph into by the variable-value of each variable and correspondence interval;
Arithmetic element, for carrying out interval arithmetic by interval for the variable-value of each variable described in input by the described controlling stream graph of traversal;
Judging unit, for judging whether the current interval computing of arbitrary variable conflicts, and terminates current interval computing when conflicting, is input to described updating block when not contradiction by judged result;
Updating block, for current operation result and last operation result are compared, reduce if current interval operation result has than described last interval arithmetic result, then current interval operation result is set to new initial conditions, is input to interval arithmetic unit and proceeds interval arithmetic;
Storage unit, current variable interval during for current interval operation result described in described judging unit and described last interval arithmetic being come to the same thing carries out compressing and is saved in incipient stability variable-value interval.
8. software test case automatic creation system according to claim 6, is characterized in that, described Test cases technology module comprises:
Assignment unit, for selecting rollback value for described current variable;
Current variable interval arithmetic element, for importing described rollback value into Ingress node condition, carries out interval arithmetic by traveling through described controlling stream graph;
Interval arithmetic judging unit, for judging whether current interval computing conflicts, when conflicting according to contradictory information choose next rollback value or backtracking after again for current variable chooses rollback value, and re-start interval arithmetic, if again without forerunner's variable, then branch and bound failure, Test cases technology failure;
Comparing unit, for current interval computing not contradiction time, the result of current interval operation result and last interval arithmetic is compared, if the result of current interval computing is less than the result of described last interval arithmetic, then current interval operation result is set to new initial conditions, is input to current variable interval arithmetic element and proceeds interval arithmetic;
Test case storage unit, current variable interval during for current interval operation result described in described judging unit and described last interval arithmetic being come to the same thing carries out compressing and is saved in incipient stability infinitely variable interval, generating test use case.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410562727.9A CN104317708B (en) | 2014-10-21 | 2014-10-21 | The software test case automatic generating method and system of the interval arithmetic based on iteration |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410562727.9A CN104317708B (en) | 2014-10-21 | 2014-10-21 | The software test case automatic generating method and system of the interval arithmetic based on iteration |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104317708A true CN104317708A (en) | 2015-01-28 |
CN104317708B CN104317708B (en) | 2017-06-13 |
Family
ID=52372943
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410562727.9A Expired - Fee Related CN104317708B (en) | 2014-10-21 | 2014-10-21 | The software test case automatic generating method and system of the interval arithmetic based on iteration |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104317708B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104809067A (en) * | 2015-05-07 | 2015-07-29 | 北京邮电大学 | Equality constraint-oriented test case generation method and device |
CN109669436A (en) * | 2018-12-06 | 2019-04-23 | 广州小鹏汽车科技有限公司 | A kind of method for generating test case and device of the functional requirement based on electric car |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5831998A (en) * | 1996-12-13 | 1998-11-03 | Northern Telecom Limited | Method of testcase optimization |
CN101436128A (en) * | 2007-11-16 | 2009-05-20 | 北京邮电大学 | Software test case automatic generating method and system |
CN103617115A (en) * | 2013-10-30 | 2014-03-05 | 北京信息控制研究所 | Runtime error analytical method based on abstract interpretation and model verification |
-
2014
- 2014-10-21 CN CN201410562727.9A patent/CN104317708B/en not_active Expired - Fee Related
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5831998A (en) * | 1996-12-13 | 1998-11-03 | Northern Telecom Limited | Method of testcase optimization |
CN101436128A (en) * | 2007-11-16 | 2009-05-20 | 北京邮电大学 | Software test case automatic generating method and system |
CN103617115A (en) * | 2013-10-30 | 2014-03-05 | 北京信息控制研究所 | Runtime error analytical method based on abstract interpretation and model verification |
Non-Patent Citations (2)
Title |
---|
XING YING 等: ""Intelligent test case generation based on branch and bound"", 《THE JOURNAL OF CHINA UNIVERSITIES OF POSTS AND TELECOMMUNICATIONS》 * |
刘莉 等: ""提高区间运算的循环处理精度"", 《清华大学学报(自然科学版)》 * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104809067A (en) * | 2015-05-07 | 2015-07-29 | 北京邮电大学 | Equality constraint-oriented test case generation method and device |
CN104809067B (en) * | 2015-05-07 | 2017-11-17 | 北京邮电大学 | Towards the method for generating test case and device of equality constraint |
CN109669436A (en) * | 2018-12-06 | 2019-04-23 | 广州小鹏汽车科技有限公司 | A kind of method for generating test case and device of the functional requirement based on electric car |
CN109669436B (en) * | 2018-12-06 | 2021-04-13 | 广州小鹏汽车科技有限公司 | Test case generation method and device based on functional requirements of electric automobile |
Also Published As
Publication number | Publication date |
---|---|
CN104317708B (en) | 2017-06-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10642832B1 (en) | Reducing the domain of a subquery by retrieving constraints from the outer query | |
US11604796B2 (en) | Unified optimization of iterative analytical query processing | |
CN111104335B (en) | C language defect detection method and device based on multi-level analysis | |
CN110688393B (en) | Query statement optimization method and device, computer equipment and storage medium | |
CN103729580A (en) | Method and device for detecting software plagiarism | |
CN104424087A (en) | Web page element positioning method, apparatus and system | |
CN113283613B (en) | Deep learning model generation method, optimization method, device, equipment and medium | |
CN106293677A (en) | A kind of code conversion method and device | |
CN104778032A (en) | Method and equipment used for carrying out continuous integration | |
CN100559347C (en) | A kind of recognition methods of nested loop structure | |
CN111444220A (en) | Cross-platform SQ L query optimization method combining rule driving and data driving | |
CN105224452A (en) | A kind of prediction cost optimization method for scientific program static analysis performance | |
WO2015188026A1 (en) | Data-dependent control flow reduction | |
CN104317708A (en) | Software testing case automatic generating method and system based on iterative interval arithmetic | |
CN115185818A (en) | Program dependence cluster detection method based on binary set | |
CN108897678B (en) | Static code detection method, static code detection system and storage device | |
Bleiholder et al. | Query planning in the presence of overlapping sources | |
CN107679107A (en) | A kind of grid equipment accessibility querying method and system based on chart database | |
Kim et al. | Performance evaluation and tuning for MapReduce computing in Hadoop distributed file system | |
JP2012123592A (en) | Optimization program, apparatus and program | |
CN115934106A (en) | Method for rapidly detecting apt warehouse source dependence integrity | |
CN103914380B (en) | Boundary value test method in structured testing and system thereof | |
Tukaram | Design and development of software tool for code clone search, detection, and analysis | |
US20190294534A1 (en) | Program usability performance classification | |
JP6087472B2 (en) | Program diagram creating apparatus, program diagram creating method, and program diagram creating program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20170613 |