CN104317708B - The software test case automatic generating method and system of the interval arithmetic based on iteration - Google Patents
The software test case automatic generating method and system of the interval arithmetic based on iteration Download PDFInfo
- Publication number
- CN104317708B CN104317708B CN201410562727.9A CN201410562727A CN104317708B CN 104317708 B CN104317708 B CN 104317708B CN 201410562727 A CN201410562727 A CN 201410562727A CN 104317708 B CN104317708 B CN 104317708B
- 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.)
- Active
Links
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The present invention relates to the software test case automatic generating method and system of a kind of interval arithmetic based on iteration, including:S1, the predefined paths read in program to be measured, the variable-value that each variable of the predefined paths is obtained by the controlling stream graph for traveling through the program to be measured are interval;S2, the interval arithmetic traversal controlling stream graph that variable-value interval is passed through into iteration, the incipient stability variable-value for obtaining each variable are interval;S3, the infinitely variable interval to the incipient stability variable-value in interval carry out initialization process, and the controlling stream graph is traveled through by the interval arithmetic of iteration, and it is interval that operation result is saved in into the incipient stability variable-value;S4, variable is ranked up according to default mechanism, and determines current variable;S5, the incipient stability variable-value interval to the current variable carry out rollback computing, the interval arithmetic of iteration and trace-back operation, generate test case;S6, the test case to generating are verified.
Description
Technical field
The present invention relates to software testing technology, more particularly to a kind of software test case of the interval arithmetic based on iteration is certainly
Dynamic generation method and system.
Background technology
Software test is before software puts into operation, to the final multiple of software requirement analysis, design specification and coding
Examine, be the committed step of software quality assurance.Statistics shows that software test is to account for whole software development expense with the expense safeguarded
More than 50%.In software test, many method of testings include substantial amounts of artificial operation, and these operations are having been manually done
When irksome and easy error, What is more, scope beyond problem is calculated by hand or is in manual methods
It is completely unworkable.In order to reduce the cost of manual testing and improve the reliability of test, researcher is devoted to realizing always
Test automation, and one of them important activity is just automatically generated test case.
In numerous method for testing software, the Test cases technology problem (referred to as problem Q) of path-oriented can be retouched
State for:Any one paths W in a program or program module P and P is given, a variable xi is if there is in program module
In one of P input statement or P a |input paramete, then xi is called an input variable of P.Input variable xi's determines
Adopted domain Dxi is all possible value set of xi.One input vector x={ x1, x2 ..., xm } ∈ (Dx1 × Dx2 × ... ×
Dxm) it is referred to as the program input of program module P, referred to as the one of P input, wherein m is the number of input variable in P.If
All input datas of P are expressed as solution space D, seek x ∈ D, and its target is at the end of test so that with x be input operation journey
Sequence module P, program is run along path W.Research shows, for arbitrary P and W, in the absence of general efficient algorithm solution x, and
And cannot ensure that W must be reachable path, need to judge the accessibility of W during test case is generated.Current road
The Test cases technology of footpath W is mainly manually completed, it is necessary to the substantial amounts of time.Under many circumstances, if path W compares
It is complicated, it may for example comprise branching ratio it is more, or branch is more complicated, and manually generated test case is almost unlikely.
In the enterprise for being engaged in software test both at home and abroad at present, mostly generated using manual type or computer-assisted way
Use-case.Both generation method of test example shortcomings be:1) generation use-case requires a great deal of time, and testing efficiency is low;
2) the software test personnel of specialty are needed, and needs the personnel to be very familiar with tested software;3) test effect is with a low credibility.
The content of the invention
The present invention provides the software test case automatic generating method and system of a kind of interval arithmetic based on iteration, can
According to the controlling stream graph of given software under testing program, satisfactory test case is generated for specified path, improve soft
The efficiency and automaticity of part test.Treatment is iterated to the interval arithmetic during Test cases technology simultaneously, to reach
To infeasible paths detection and the purpose of variable-value interval narrowing.
According to above-mentioned purpose, automatically generated the invention provides a kind of software test case of the interval arithmetic based on iteration
Method, methods described includes:
S1, the predefined paths read in program to be measured, obtain described pre- by the controlling stream graph for traveling through the program to be measured
The variable-value for determining each variable in path is interval;
S2, the interval arithmetic traversal controlling stream graph that variable-value interval is passed through into iteration, obtain described in each
The incipient stability variable-value of variable is interval;
S3, the infinitely variable interval to the incipient stability variable-value in interval carry out initialization process, pass through
The interval arithmetic of iteration travels through the controlling stream graph, and it is interval that operation result is saved in into the incipient stability variable-value;
S4, variable is ranked up according to default mechanism, and determines current variable;
S5, the incipient stability variable-value interval to the current variable carry out rollback computing, the interval arithmetic of iteration and
Trace-back operation, generates test case;
S6, the test case to generating are verified.
Wherein, the step S2 is specifically included:
S21, the Ingress node by the incoming controlling stream graph of each described variable and corresponding variable-value interval, lead to
Cross and travel through the controlling stream graph and carry out interval arithmetic;
S22, when the current interval computing of any variable conflicts, then decision paths are unreachable, terminate described working as
Preceding interval arithmetic;
S23, the current interval computing not contradiction when all variables, judge current interval operation result with last area
Between computing result it is whether identical;
If S24, the current interval operation result of any variable are different with the last interval arithmetic result, sentence
Whether the result of the current interval computing of disconnected any variable has diminution than the result of the last interval arithmetic, if there is contracting
It is small, the current interval operation result of all variables is set to new input condition, return to step S21 proceeds area
Between computing, if not reducing, terminate current interval computing;
If S25, the current interval operation result of all variables are identical with the last interval arithmetic result,
The current variable interval of each variable is compressed and is saved in the incipient stability of each variable and is become and is measured
In value interval.
Wherein, the step S3 is specifically included:
S31, to each described variable incipient stability variable-value interval in infinitely variable interval according to interval
Initialization strategy is compressed, and forms the bounded variable interval of each variable;
S32, the entrance section that each described variable and corresponding bounded variable interval are passed to the controlling stream graph
Point, interval arithmetic is carried out by traveling through the controlling stream graph;
S33, conflict when the current interval computing of any variable, by the bounded variable value area for conflicting
Between border be amplified, then re-execute step S32;
S34, the current interval computing not contradiction when all variables, judge current interval operation result with last area
Between computing result it is whether identical;
If S35, the current interval operation result of any variable are different with the last interval arithmetic result, sentence
Whether the result of the current interval computing of disconnected any variable has diminution than the result of the last interval arithmetic, if there is contracting
It is small, the current interval operation result of all variables is set to new input condition, return to step S32 proceeds area
Between computing, if not reducing, terminate current interval computing;
If S36, the current interval operation result of all variables are identical with last interval arithmetic result, will be each
The current interval computing of the individual variable is compressed and is saved in the incipient stability variable-value interval.
Wherein, the step S5 is specifically included:
S51, be the current variable selection fallback value;
S52, by the Ingress node of the incoming controlling stream graph of the fallback value, area is carried out by traveling through the controlling stream graph
Between computing;
S53, judge whether current interval computing conflicts, generation then carries out step S54, otherwise perform step S56;
S54, next fallback value is chosen according to contradictory information, then perform step S52 and judge whether to conflict, when described
When the interval arithmetic of all fallback values of current variable all conflicts, step S55 is performed;
S55, current variable is recalled, then again for the current variable chooses fallback value, and perform step
S52, when the interval arithmetic of all fallback values of the current variable after backtracking all conflicts, terminates computing;
S56, when interval arithmetic not contradiction, judge current interval operation result and last interval arithmetic result whether phase
Together;
If S57, the current interval operation result of any variable are different with the last interval arithmetic result, sentence
Whether the result of the current interval computing of disconnected any variable has diminution than the result of the last interval arithmetic, if there is contracting
It is small, the current interval operation result of all variables is set to new input condition, return to step S52 proceeds area
Between computing, if not reducing, terminate current interval computing;
If S58, the current interval operation result of all variables are identical with last interval arithmetic result, ought
The incipient stability variable-value interval of preceding variable is saved in stabilization variable-value interval, generates test case.
Wherein, step S6 includes:
S61, the test case driving program to be measured with the generation, and according to the actual execution of code record of inserting
Path;
S62, the relatively actual path for performing and preset path, whether the path and preset path for judging actual execution accord with
Close, the Test cases technology failure if not meeting;If met, the test case that will be obtained is stored and returned it into
To user.
According to another aspect of the present invention, there is provided a kind of software test case of the interval arithmetic based on iteration is given birth to automatically
Into system, the system includes:
Pretreatment module, for reading the predefined paths in program to be measured, by the controlling stream for traveling through the program to be measured
The variable-value that figure obtains each variable of the predefined paths is interval;
Initial interval computing module, for the interval interval arithmetic by iteration of the variable-value to be traveled through into the control
Flow graph, the incipient stability variable-value for obtaining each variable is interval;
Infinitely variable interval arithmetic module, for the infinitely variable value area in incipient stability variable-value interval
Between carry out initialization process, the controlling stream graph is traveled through by the interval arithmetic of iteration, and the operation result is saved in institute
State incipient stability variable-value interval;
Order module, for being ranked up to variable according to default mechanism, and determines current variable;
Test cases technology module, rollback fortune is carried out for the incipient stability variable-value interval to the current variable
Calculation, the interval arithmetic of iteration and trace-back operation, generate test case;
Authentication module, for being verified to the test case for generating.
Wherein, the initial interval computing module includes:
Input block, for by the entrance section of the interval incoming controlling stream graph of each variable and corresponding variable-value
Point;
Arithmetic element, for will be input into described in each variable variable-value interval entered by traveling through the controlling stream graph
Row interval arithmetic;
Whether judging unit, the current interval computing for judging any variable conflicts, and when conflicting, terminates
Current interval computing, will determine that result is input to the updating block when not contradiction;
Updating block, for current operation result to be compared with last operation result, if current interval computing
Result has diminution than the last interval arithmetic result, then current interval operation result is set into new input condition, defeated
Enter to interval arithmetic unit and proceed interval arithmetic;
Memory cell, for by current interval operation result described in the judging unit and the last interval arithmetic
Current variable interval when result is identical is compressed and is saved in incipient stability variable-value interval.
Wherein, the Test cases technology module includes:
Assignment unit, for selecting fallback value for the current variable;
Current variable interval arithmetic element, for by the incoming Ingress node condition of the fallback value, by traveling through
Stating controlling stream graph carries out interval arithmetic;
Interval arithmetic judging unit, for judging whether current interval computing conflicts, when current interval computing occurs
Contradiction is again current variable selection fallback value after then choosing next fallback value or backtracking according to contradictory information, and re-starts area
Between computing, if again without forerunner's variable, branch and bound failure, Test cases technology failure;
Comparing unit, in current interval computing not contradiction, by current interval operation result and last interval fortune
The result of calculation is compared, if the result of current interval computing is smaller than the result of the last interval arithmetic, will be current
Interval arithmetic result is set to new input condition, is input to current variable interval arithmetic element and proceeds interval fortune
Calculate;
Test case memory cell, for by current interval operation result described in the judging unit and the last time
Current variable interval when interval arithmetic result is identical is compressed and is saved in incipient stability infinitely variable interval,
Generation test case.
The software test case automatic generating method and system of the interval arithmetic based on iteration of the invention, as a result of
The interval arithmetic technology of iteration, when each path analysis can farthest refinement to reach fixed point, so energy
It is enough to carry out path accessibility judgement before use-case generation starts, exactly according to given software under testing if path is reachable
Program element search obtains satisfactory test case set, while the present invention can be also tested the test case for generating
Card, improves the accuracy of test case, substantially increases the efficiency and automaticity of software test.
Brief description of the drawings
The features and advantages of the present invention can be more clearly understood from by reference to accompanying drawing, accompanying drawing is schematical without that should manage
Solution is to carry out any limitation to the present invention, in the accompanying drawings:
Fig. 1 shows the flow of the software test case automatic generating method of the interval arithmetic based on iteration of the invention
Figure.
The particular flow sheet of the step of Fig. 2 shows software test case automatic generating method of the invention S2.
The particular flow sheet of the step of Fig. 3 shows software test case automatic generating method of the invention S3.
The particular flow sheet of the step of Fig. 4 shows software test case automatic generating method of the invention S5.
Fig. 5 shows the structured flowchart of software test case automatic creation system of the invention.
Specific 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 invention, its basic thought is:It is first
The given path in software under testing source program is first read, is pre-processed by traveling through controlling stream graph, including expression formula is extracted, obtained
Variable levels and correlated variables closure collection, initializing variable property list are taken, so that acquisition approach end each variable-value of node
It is interval;Then, it is whether reachable by iterating over controlling stream graph decision paths, and input interval is compressed;Then, for
Whether infinite border is reachable by iterating over controlling stream graph decision paths, and input interval is compressed;Then, by certainly
Plan mechanism is ranked up to variable, and by rollback computing, implication computing and trace-back operation, generates test case;Finally, drive
Tested program is performed, the actual execution route and destination path of the above-mentioned program element for being given are compared, check that gained is surveyed
Whether example on probation meets required path.
In the present embodiment, the abstract syntax tree of abstract program to be measured and controlling stream map generalization belongs to prior art, is
Description is simple, in the present embodiment no longer describes.
Abstract syntax tree includes representing the object and symbol table of type information, and they are connected into tree structure, and this is
The most basic output of compiler front-end, abstract syntax tree includes all of relevant information from obtained by source code, and energy
Enough syntactic structures for embodying source program completely.Above-mentioned abstract syntax tree has consistent tactic pattern, by different types of node
Composition, each class node is all described as a class formation.All of grammer tree node all supports unified visitor's mould
Formula interface, so it become convenient substantially that to abstract syntax tree by visitor carry out further multi-form processing,
Traversal is accessed and exported.
One program control flowchart is represented by (N, E, Entry, Exit).Wherein, N represents the set of node, reflects journey
Sentence and condition judgment in sequence;E represents the set of directed edge, the control flow relation in reflection program between sentence;Entry is journey
The sole inlet node that sequence is fixed;Exit uniquely exits node for program.Briefly:Controlling stream graph be exactly with it is single,
The digraph of fixed entry node and outlet node.
Fig. 1 shows the flow of the software test case automatic generating method of the interval arithmetic based on iteration of the invention
Figure.
Reference picture 1, software test case automatic generating method of the invention includes step:
S1, the predefined paths read in program to be measured, obtain described pre- by the controlling stream graph for traveling through the program to be measured
The variable-value for determining each variable in path is interval.
Specifically, step S1 includes:
Step S11, by traveling through controlling stream graph, extract the node containing expression formula, and be stored in linear list row.
Each node in step 12, the linear list of traversal step S11, extracts variable and expression formula.
By traveling through each node in linear list, expression formula in conditional statement and variable are extracted, wherein, table
Up to formula be used for condition calculating, variable as subsequent searches process operation object.This process is given along step S11
Path is carried out, during it is also contemplated that assignment statement on path.Some conditions can uniquely determine certain or some
The value of variable.And these implicit values are the same just as assignment, it is no longer necessary to search further for.It is empty that this can significantly reduce search
Between.This condition will be calculated preferentially;
For example, conditional statement:If (a==3) ..., now, the valued space of variable a can only be just { 3 };
The derivative search principle of strategy that above-mentioned preferential calculating can uniquely determine the condition of value is preferential finite region
Search:Some variables make region of search become only limited several points, in this condition initially or by some constraints
Lower this variable of first search helps to find contradiction as early as possible or searches for successfully.
For example, it is assumed that x is an integer variable, if (1≤x≤3) ..., the condition determines x ∈ [1,2,3].
Step S13, try to achieve each input variable interval of path end node.
Global variable and static variable that variable generally includes to be used in function parameter, function are originally inputted, are passed through first
Ergodic abstract syntax tree, identifies these variables.The interval of variable is generally according to corresponding class in the language of tested program
Type and operating system environment determine.The form of variable-value section definition is:
{ (x1, Dx1), (x2, Dx2) ... }, wherein x represents variable name, and it is interval that D represents it.
S2, the interval arithmetic traversal controlling stream graph that variable-value interval is passed through into iteration, obtain described in each
The incipient stability variable-value of variable is interval.
The particular flow sheet of the step of Fig. 2 shows Generation of software test case method of the invention S2.
Reference picture 2, step S2 is specifically included:
S21, the Ingress node by the incoming controlling stream graph of each described variable and corresponding variable-value interval, lead to
Cross and travel through the controlling stream graph and carry out interval arithmetic;
S22, when the current interval computing of any variable conflicts, then decision paths are unreachable, terminate described working as
Preceding interval arithmetic;
S23, the current interval computing not contradiction when all variables, then the result with last interval arithmetic compared
Compared with judging whether current interval operation result is identical with the result of last interval arithmetic;
If S24, the current interval operation result of any variable are different with the last interval arithmetic result, sentence
Whether the result of the current interval computing of disconnected any variable has diminution than the result of the last interval arithmetic, if there is contracting
It is small, the current interval operation result of all variables is set to new input condition, return to step S21 proceeds area
Between computing, if not reducing, terminate current interval computing;
If S25, the current interval operation result of all variables are identical with the last interval arithmetic result,
The current variable interval of each variable is compressed and is saved in the incipient stability of each variable and is become and is measured
In value interval.
In the present embodiment, infeasible paths refer to that the path is may never to be held in given input interval
OK.
, there are substantial amounts of infeasible paths in general program in analysis shows.During test case is produced, selection
Infeasible paths are possible, and this is also one of principal element of influence testing efficiency, therefore should be stopped as early as possible to the path
Calculating, exit Test cases technology module.
For example:
In the above example, each input variable interval of path end node for (a, [1 ,+inf]), (b, [- inf ,-
5]) }, it can be seen that this interval is simultaneously unsatisfactory for first condition in path;Three if conditions take dividing for true value in program
The path of Zhi Zucheng is actually an infeasible paths, because b>a,b<- 4 and a>0 these conditions are contradiction.
Step S2 is traveled through to controlling stream graph again with { (a, [1 ,+inf]), (b, [- inf, -5]) } as input, then
Just conflicted at first node, so as to determine infeasible paths, the implementation procedure of algorithm finished in advance, it is to avoid
Unnecessary work below.
For non-infeasible paths, then according to the assignment and conditional statement being originally inputted in the domain of definition of variable, program, from
Space compression is carried out under above, the result of compression is:{ (x1, D ' x1), (x2, D ' x2) ... };
The domain of definition for being originally inputted variable has been determined by type of variables and operating system environment, in calculation procedure
Assignment and conditional statement restriction scope, the valued space to being originally inputted variable further compresses.
For example:
In the above example, each input variable interval of path end node for (a, [- inf ,+inf]), (b, [1 ,+
Inf]) }, it can be seen that this interval not fully meets first condition in path, if being with this interval
Input carries out follow-up computing and has many work and be wasted in be unsatisfactory for condition b<In those intervals of a;And with this path end
The interval arithmetic that the interval of tail node is iterated as input, obtains the variable-value area of each node after iteration stabilization
Between be:
S3, the infinitely variable interval to the incipient stability variable-value in interval carry out initialization process, pass through
The interval arithmetic of iteration travels through the controlling stream graph, and it is interval that operation result is saved in into the incipient stability variable-value;
The particular flow sheet of the step of Fig. 3 shows Generation of software test case method of the invention S3.
Reference picture 3, step S3 is specifically included:
S31, to each described variable incipient stability variable-value interval in infinitely variable interval according to interval
Initialization strategy is compressed, and forms the bounded variable interval of each variable.
The variable-value interval of step S2 outputs is sometimes had as [a ,+inf], [- inf, b], [- inf ,+inf]
Infinite border, for variable finds test case and makes it ensure that path is very huge up to its workload in so unbounded interval
Greatly, the absolute value of the test case of its generation is often very huge, is unfavorable for the understanding and checking of user.So, for variable
There is three cases above in interval, then the interval of bounded is turned to according to certain principle.
S32, the entrance section that each described variable and corresponding bounded variable interval are passed to the controlling stream graph
Point, interval arithmetic is carried out by traveling through the controlling stream graph;
S33, when the current interval computing of any variable conflicts, illustrate that interval initialization strategy causes effectively solution
It is excluded outside initial interval, is then amplified the border of the bounded variable interval for conflicting, then holds again
Row step S32.
S34, the current interval computing not contradiction when all variables, then the result with last interval arithmetic compared
Compared with judging whether current interval operation result is identical with the result of last interval arithmetic.
An interval arithmetic in individual paths from the inlet to the outlet, used as function, it is monotone decreasing.Therefore can be with
Demonstration, this function can be stabilized to a fixed point by iteration, and (empty set can regard a kind of special circumstances as, and it is interval
The infimum of collection).Therefore, after each interval arithmetic terminates, it is required for being contrasted with the result of last interval arithmetic examining
Look into whether iteration stable.
If S35, the current interval operation result of any variable are different with the last interval arithmetic result, sentence
Whether the result of the current interval computing of disconnected any variable has diminution than the result of the last interval arithmetic, if there is contracting
It is small, the current interval operation result of all variables is set to new input condition, return to step S32 proceeds area
Between computing, if not reducing, terminate current interval computing.
If S36, the current interval operation result of all variables are identical with last interval arithmetic result, will be each
The current interval computing of the individual variable is compressed and is saved in the incipient stability variable-value interval.
S4, variable is ranked up according to default mechanism, and determines current variable.
S5, the incipient stability variable-value interval to the current variable carry out rollback computing, the interval arithmetic of iteration and
Trace-back operation, generates test case.
The particular flow sheet of the step of Fig. 4 shows Generation of software test case method of the invention S5.
Reference picture 4, step S5 is specifically included:
S51, be the current variable selection fallback value.
S52, the Ingress node by the incoming controlling stream graph of the fallback value, area is carried out by traveling through the controlling stream graph
Between computing.
For current variable selects fallback value, now the interval shape of current variable such as [V, V], that is, is expressed as bound equal
Range format, and the interval of its dependent variable (having retracted and not retracting) be to maintain it is constant, i.e., apart from last iteration stabilization
Unique change is exactly that the interval of current variable becomes a determination value from a bounded interval in interval.Have at this
It is that, comprising effectively solution, the otherwise interval arithmetic of last iteration can judge contradiction that battery limit (BL) is interior.Therefore, need to only judge selected
This fallback value selected whether the effective solution in the interval.So as to, incoming Ingress node condition be all variables interval (when
The interval of preceding variable is determination value), carry out interval arithmetic by traveling through controlling stream graph.
S53, judge whether current interval computing conflicts, conflict, it is not to work as that determination step S51 is selected
Effective solution in preceding variable-value interval, it is therefore desirable to next fallback value is chosen according to contradictory information, i.e., then carries out step S54,
Otherwise perform step S56;
S54, next fallback value is chosen according to contradictory information, judge whether to conflict according to step S52, when described current
When the interval arithmetic of all fallback values of variable all conflicts, step S55 is performed;
S55, current variable is recalled, then again for the current variable chooses fallback value, and perform step
S52, when the interval arithmetic of all fallback values of the current variable after backtracking all conflicts, terminates computing;
S56, when interval arithmetic not contradiction, interval arithmetic result is compared with last round of interval arithmetic result, judge
Whether current interval operation result is identical with the result of last interval arithmetic;
If S57, the current interval operation result of any variable are different with the last interval arithmetic result, sentence
Whether the result of the current interval computing of disconnected any variable has diminution than the result of the last interval arithmetic, if there is contracting
It is small, the current interval operation result of all variables is set to new input condition, return to step S52 proceeds area
Between computing, if not reducing, terminate current interval computing.
If S58, the current interval operation result of current all variables are identical with last operation result, will currently become
The incipient stability variable-value interval of amount is saved in stabilization variable-value interval, generates test case.
S6, the test case to generating are verified.
Step S6 includes:
S61, extra code is inserted in program to be measured, to obtain the information of program to be measured behavior upon execution;
Extra code is inserted in tested software program, to obtain the information of program behavior when executed;Above-mentioned volume
Outer code can be sentence.Inserting is main to be determined to insert point according to controlling stream graph, beginning in tested program controlling stream graph,
Bifurcation is implemented to insert to tested program, the inserting sentence tree node on abstract syntax tree is then generated, then by abstract syntax
Again conversion is output as source program to tree.
For example, following procedure:
By shape after automatic inserting such as:
During tested program is performed, it is possible to the routing information of the actual execution of collection procedure.
S62, the test case driving program to be measured with the generation, and according to the actual execution of code record of inserting
Path;
S63, the relatively actual path for performing and preset path, whether the path and preset path for judging actual execution accord with
Close, the Test cases technology failure if not meeting;If met, the test case that will be obtained is stored and returned it into
To user.
Inserting code above have recorded actual execution route, itself and destination path be contrasted, if do not met
(differing), illustrates that the test case for obtaining can not cover path to be measured it is necessary to regenerate, and this is due to test case
Some in generating process simplify what approximate calculation was caused.
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 by
Ranging sequence branch number reaches 601, and variable number is 50.
The interval arithmetic contrast experiment tested program of the iteration of table 1 is introduced
Interval arithmetic contrast and experiment (the A of the iteration of table 2:Using the interval arithmetic of iteration;B:The interval of iteration is not used
Computing)
Knowable to result above, interval iterative process may determine that some infeasible paths.There is one in this example not
Reachable path is judged by iterative process.Branch and bound can be other 13 after this paths is eliminated
Reachable path all generates test case.For constraining more complicated path, being without the interval iterative process of process cannot
Solve, in this experiment, 2 in 14 paths only could generate test case up to path by the process of iteration.
Example 2:The experiment of this part mainly tests this Test cases technology system and can support how many expression formulas:Using
The interval arithmetic of iteration, is stepped up variable number and expression formula number is tested, and test can at most process how many
Variable and expression formula.Experimental result is as shown in table 3.From table 3 it can be seen that for the tested program that branch's number is 50 to 601, mesh
Preceding system can generate the test case of 100% sentence covering.
The logarithm value type program test use-case of table 3 generates result
Knowable to result from the above mentioned, the area of iteration is employed due to software test case automatic creation system of the invention
Between computing, it is possible to obtaining satisfactory test case according to given software under testing program element search exactly
Set, and the anticipation of infeasible paths can be carried out, the efficiency and automaticity of software test are greatly improved, it is preferably
Method for generating test case based on path.
In an alternative embodiment of the invention, there is provided a kind of software test case of the interval arithmetic based on iteration is given birth to automatically
Into system.
Fig. 5 shows the structured flowchart of software test case automatic creation system of the invention.
Reference picture 5, the system includes:
Pretreatment module 10, for reading the predefined paths in program to be measured, by the control for traveling through the program to be measured
The variable-value that flow graph obtains each variable of the predefined paths is interval;
Initial interval computing module 20, for the interval interval arithmetic by iteration of the variable-value to be traveled through into the control
Flow graph processed, the incipient stability variable-value for obtaining each variable is interval;
Infinitely variable interval arithmetic module 30, for the infinitely variable value in incipient stability variable-value interval
Interval carries out initialization process, travels through the controlling stream graph by the interval arithmetic of iteration, and the operation result is saved in
The incipient stability variable-value is interval;
Order module 40, for being ranked up to variable according to default mechanism, and determines current variable;
Test cases technology module 50, rollback fortune is carried out for the incipient stability variable-value interval to the current variable
Calculation, the interval arithmetic of iteration and trace-back operation, generate test case;
Authentication module 60, for being verified to the test case for generating.
Wherein, initial interval computing module 20 includes:
Input block 201, for by the entrance of the interval incoming controlling stream graph of each variable and corresponding variable-value
Node;
Arithmetic element 202, for will be input into described in each variable variable-value interval by traveling through the controlling stream
Figure carries out interval arithmetic;
Whether judging unit 203, the current interval computing for judging any variable conflicts, and is tied when conflicting
Beam current interval computing, will determine that result is input to the updating block when not contradiction;
Updating block 204, for current operation result to be compared with last operation result, if current interval is transported
Calculate result has diminution than the last interval arithmetic result, then current interval operation result is set into new input condition,
It is input to interval arithmetic unit and proceeds interval arithmetic;
Memory cell 205, for current interval operation result described in the judging unit and the last time is interval
Current variable interval when operation result is identical is compressed and is saved in incipient stability variable-value interval.
Wherein, Test cases technology module 40 includes:
Assignment unit 401, for selecting fallback value for the current variable;
Current variable interval arithmetic element 402, for by the incoming Ingress node condition of the fallback value, by traversal
The controlling stream graph carries out interval arithmetic;
Interval arithmetic judging unit 403, for judging whether current interval computing conflicts, when conflicting according to
Contradictory information is again current variable selection fallback value after choosing next fallback value or backtracking, and re-starts interval arithmetic, such as
Fruit is again without forerunner's variable, then branch and bound failure, Test cases technology failure;
Updating block 404 is judged, in current interval computing not contradiction, by current interval operation result and last time
The result of interval arithmetic is compared, if the result of current interval computing is smaller than the result of the last interval arithmetic,
Current interval operation result is set to new input condition, current variable interval arithmetic element is input to and is proceeded area
Between computing;
Test case memory cell 405, for by current interval operation result described in the judging unit and described
Current variable interval when one time interval arithmetic result is identical is compressed and is saved in incipient stability infinitely variable value
Interval, generates test case
The software test case automatic generating method and system of the interval arithmetic based on iteration of the invention, as a result of
The interval arithmetic technology of iteration, when each path analysis can farthest refinement to reach fixed point, so energy
It is enough to carry out path accessibility judgement before use-case generation starts, exactly according to given software under testing if path is reachable
Program element search obtains satisfactory test case set, while the present invention can be also tested the test case for generating
Card, improves the accuracy of test case, substantially increases the efficiency and automaticity of software test.
Although being described in conjunction with the accompanying embodiments of the present invention, those skilled in the art can not depart from this hair
Various modifications and variations are made in the case of bright spirit and scope, such modification and modification are each fallen within by appended claims
Within limited range.
Claims (6)
1. the software test case automatic generating method of the interval arithmetic of iteration is based on, it is characterised in that methods described includes:
S1, the predefined paths read in program to be measured, the predetermined road is obtained by the controlling stream graph for traveling through the program to be measured
The variable-value of each variable in footpath is interval;
S2, the interval arithmetic traversal controlling stream graph that variable-value interval is passed through into iteration, obtain each variable
Incipient stability variable-value it is interval;
S3, the infinitely variable interval to the incipient stability variable-value in interval carry out initialization process, obtain bounded
Variable-value is interval, and the bounded variable interval is traveled through into the controlling stream graph by the interval arithmetic of iteration, and will
It is interval that operation result is saved in the incipient stability variable-value;
S4, variable is ranked up according to default mechanism, and determines current variable;
S5, the incipient stability variable-value interval to the current variable carry out rollback computing, the interval arithmetic of iteration and backtracking
Computing, generates test case;
S6, the test case to generating are verified;
The step S2 is specifically included:
S21, the Ingress node by the interval incoming controlling stream graph of each described variable and corresponding variable-value, by time
Going through the controlling stream graph carries out interval arithmetic;
S22, when the current interval computing of any variable conflicts, then decision paths are unreachable, terminate described to work as proparea
Between computing;
S23, the current interval computing not contradiction when all variables, judge current interval operation result with last interval fortune
Whether the result of calculation is identical;
If S24, the current interval operation result of any variable are different with the last interval arithmetic result, judge to appoint
Whether the result of the current interval computing of variable described in has diminution compared with the result of the last interval arithmetic, if there is contracting
It is small, the current interval operation result of all variables is set to new input condition, return to step S21 proceeds area
Between computing, if not reducing, terminate current interval computing;
If S25, the current interval operation result of all variables are identical with the last interval arithmetic result, will be each
The current variable interval of the individual variable is compressed and is saved in the incipient stability variable-value area of each variable
Between in.
2. software test case automatic generating method according to claim 1, it is characterised in that the step S3 is specifically wrapped
Include:
S31, to the infinitely variable interval in the incipient stability variable-value interval of variable each described according to interval initial
Change strategy to be compressed, form the bounded variable interval of each variable;
S32, the Ingress node that each described variable and corresponding bounded variable interval are passed to the controlling stream graph, lead to
Cross and travel through the controlling stream graph and carry out interval arithmetic;
S33, conflict when the current interval computing of any variable, by the bounded variable interval for conflicting
Border is amplified, and then re-executes step S32;
S34, the current interval computing not contradiction when all variables, judge current interval operation result with last interval fortune
Whether the result of calculation is identical;
If S35, the current interval operation result of any variable are different with the last interval arithmetic result, judge to appoint
Whether the result of the current interval computing of variable described in has diminution than the result of the last interval arithmetic, if having diminution
The current interval operation result of all variables is set to new input condition, return to step S32 proceeds interval fortune
Calculate, if not reducing, terminate current interval computing;
If S36, the current interval operation result of all variables are identical with last interval arithmetic result, by each institute
The current interval computing for stating variable is compressed and is saved in the incipient stability variable-value interval.
3. software test case automatic generating method according to claim 1, it is characterised in that the step S5 is specifically wrapped
Include:
S51, be the current variable selection fallback value;
S52, by the Ingress node of the incoming controlling stream graph of the fallback value, interval fortune is carried out by traveling through the controlling stream graph
Calculate;
S53, judge whether current interval computing conflicts, generation then carries out step S54, otherwise perform step S56;
S54, next fallback value is chosen according to contradictory information, then perform step S52 and judge whether to conflict, when described current
When the interval arithmetic of all fallback values of variable all conflicts, step S55 is performed;
S55, current variable is recalled, then again for the current variable chooses fallback value, and perform step S52, when
When the interval arithmetic of all fallback values of the current variable after backtracking all conflicts, terminate computing;
S56, when interval arithmetic not contradiction, judge whether current interval operation result identical with the result of last interval arithmetic;
If S57, the current interval operation result of any variable are different with the last interval arithmetic result, judge to appoint
Whether the result of the current interval computing of variable described in has diminution than the result of the last interval arithmetic, if having diminution
The current interval operation result of all variables is set to new input condition, return to step S52 proceeds interval fortune
Calculate, if not reducing, terminate current interval computing;
If S58, the current interval operation result of all variables are identical with last interval arithmetic result, will currently become
The incipient stability variable-value interval of amount is saved in stabilization variable-value interval, generates test case.
4. software test case automatic generating method according to claim 1, it is characterised in that the step S6 includes:
S61, extra code is inserted in program to be measured, to obtain the information of program to be measured behavior upon execution;
S62, the test case driving program to be measured with the generation, and according to the actual road for performing of code record of inserting
Footpath;
Whether S63, the relatively actual path for performing and preset path, the path and preset path for judging actual execution meet, such as
Fruit does not meet the then Test cases technology failure;If met, the test case that will be obtained stores and is returned to use
Family.
5. the software test case automatic creation system of the interval arithmetic of iteration is based on, it is characterised in that the system includes:
Pretreatment module, for reading the predefined paths in program to be measured, is obtained by the controlling stream graph for traveling through the program to be measured
Variable-value to each variable of the predefined paths is interval;
Initial interval computing module, for the interval interval arithmetic by iteration of the variable-value to be traveled through into the controlling stream
Figure, the incipient stability variable-value for obtaining each variable is interval;
Infinitely variable interval arithmetic module, for entering to the infinitely variable interval in incipient stability variable-value interval
Row initialization process, obtains bounded variable interval, and the interval arithmetic that the bounded variable interval is passed through into iteration
The controlling stream graph is traveled through, and it is interval that operation result is saved in into the incipient stability variable-value;
Order module, for being ranked up to variable according to default mechanism, and determines current variable;
Test cases technology module, carries out rollback computing, changes for the incipient stability variable-value interval to the current variable
The interval arithmetic in generation and trace-back operation, generate test case;
Authentication module, for being verified to the test case for generating;
The initial interval computing module includes:
Input block, for by the Ingress node of the interval incoming controlling stream graph of each variable and corresponding variable-value;
Arithmetic element, for will be input into described in each variable variable-value interval carry out area by traveling through the controlling stream graph
Between computing;
Whether judging unit, the current interval computing for judging any variable conflicts, and terminates current when conflicting
Interval arithmetic, will determine that result is input to updating block when not contradiction;
Updating block, for current operation result to be compared with last operation result, if current interval operation result
There is diminution than the last interval arithmetic result, then current interval operation result is set to new input condition, be input to
Interval arithmetic unit proceeds interval arithmetic;
Memory cell, for by current interval operation result described in the judging unit and the last interval arithmetic result
Current variable interval when identical is compressed and is saved in incipient stability variable-value interval.
6. software test case automatic creation system according to claim 5, it is characterised in that the Test cases technology
Module includes:
Assignment unit, for selecting fallback value for the current variable;
Current variable interval arithmetic element, for by the incoming Ingress node condition of the fallback value, by traveling through the control
Flow graph processed carries out interval arithmetic;
Interval arithmetic judging unit, for judging whether current interval computing conflicts, believes when conflicting according to contradiction
Breath is chosen after next fallback value or backtracking again for current variable chooses fallback value, and re-starts interval arithmetic, if again without
Forerunner's variable, then branch and bound failure, Test cases technology failure;
Comparing unit, in current interval computing not contradiction, by current interval operation result and last interval arithmetic
Result is compared, if the result of current interval computing is smaller than the result of the last interval arithmetic, by current interval
Operation result is set to new input condition, is input to current variable interval arithmetic element and proceeds interval arithmetic;
Test case memory cell, for current interval operation result described in the judging unit and the last time is interval
Current variable interval when operation result is identical is compressed and is saved in incipient stability infinitely variable interval, generation
Test 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 CN104317708A (en) | 2015-01-28 |
CN104317708B true CN104317708B (en) | 2017-06-13 |
Family
ID=52372943
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410562727.9A Active 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) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104809067B (en) * | 2015-05-07 | 2017-11-17 | 北京邮电大学 | Towards the method for generating test case and device of equality constraint |
CN109669436B (en) * | 2018-12-06 | 2021-04-13 | 广州小鹏汽车科技有限公司 | Test case generation method and device based on functional requirements of electric automobile |
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 active Active
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 |
---|
"Intelligent test case generation based on branch and bound";XING Ying 等;《The Journal of China Universities of Posts and Telecommunications》;20140430;第21卷(第2期);第91-97页 * |
"提高区间运算的循环处理精度";刘莉 等;《清华大学学报(自然科学版)》;20111231;第51卷(第S1期);第1483-1493页 * |
Also Published As
Publication number | Publication date |
---|---|
CN104317708A (en) | 2015-01-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11263116B2 (en) | Champion test case generation | |
US10606570B2 (en) | Representing software with an abstract code graph | |
CN111104335B (en) | C language defect detection method and device based on multi-level analysis | |
CN107844415B (en) | Model detection path reduction method based on interpolation and computer | |
CN113283613B (en) | Deep learning model generation method, optimization method, device, equipment and medium | |
US10990510B2 (en) | Associating attribute seeds of regression test cases with breakpoint value-based fingerprints | |
JP4001286B2 (en) | Program maintenance support apparatus, program maintenance support method, and program | |
CN111176979B (en) | Test case generation method and device of graph database | |
US20080028380A1 (en) | Localized, incremental single static assignment update | |
US20200313994A1 (en) | Automated analysis and recommendations for highly performant single page web applications | |
US10915302B2 (en) | Identification and visualization of associations among code generated from a model and sources that affect code generation | |
JP2021533485A (en) | Control flow systems, non-transient readable media, and methods for improving program functionality | |
CN112346730B (en) | Intermediate representation generation method, computer equipment and storage medium | |
CN104317708B (en) | The software test case automatic generating method and system of the interval arithmetic based on iteration | |
US20210263837A1 (en) | Real time fault localization using combinatorial test design techniques and test case priority selection | |
CN104965687A (en) | Big data processing method and apparatus based on instruction set generation | |
CN108875914A (en) | The method and apparatus that Neural Network Data is pre-processed and is post-processed | |
CN104809067B (en) | Towards the method for generating test case and device of equality constraint | |
CN106126670B (en) | Operation data sorting processing method and device | |
US10754630B2 (en) | Build-time code section-specific compiler selection | |
CN111581101A (en) | Software model testing method, device, equipment and medium | |
Murphy et al. | The case for grammatical evolution in test generation | |
CN103914380B (en) | Boundary value test method in structured testing and system thereof | |
Asher et al. | A study of conflicting pairs of compiler optimizations | |
CN110023913A (en) | The method and apparatus of test software |
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 |