CN104809067B - Towards the method for generating test case and device of equality constraint - Google Patents

Towards the method for generating test case and device of equality constraint Download PDF

Info

Publication number
CN104809067B
CN104809067B CN201510229658.4A CN201510229658A CN104809067B CN 104809067 B CN104809067 B CN 104809067B CN 201510229658 A CN201510229658 A CN 201510229658A CN 104809067 B CN104809067 B CN 104809067B
Authority
CN
China
Prior art keywords
variable
test case
interval
program
computing
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.)
Expired - Fee Related
Application number
CN201510229658.4A
Other languages
Chinese (zh)
Other versions
CN104809067A (en
Inventor
黄俊飞
邢颖
宫云战
金大海
王雅文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing University of Posts and Telecommunications
Original Assignee
Beijing University of Posts and Telecommunications
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing University of Posts and Telecommunications filed Critical Beijing University of Posts and Telecommunications
Priority to CN201510229658.4A priority Critical patent/CN104809067B/en
Publication of CN104809067A publication Critical patent/CN104809067A/en
Application granted granted Critical
Publication of CN104809067B publication Critical patent/CN104809067B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The present invention provides a kind of method for generating test case and device towards equality constraint, and method for generating test case includes:Test cases technology request is received, program to be measured is carried in generation request;Obtain the first interval of each variable and each variable in the predefined paths, expression list, predefined paths of program to be measured;Equation in expression list, determine the first coefficient matrix and the first augmented matrix of equality constraint;Judge whether the order of the first coefficient matrix is less than the order of the first augmented matrix;If it is not, then carrying out rollback computing to each variable, the second interval of each variable is determined;Judge whether the boundary value of the second interval of each variable is equal;If equal, test case is generated according to the second interval of each variable.Method for generating test case and device provided by the invention towards equality constraint, the process of test case is generated without manual intervention, speed is fast, efficiency high, can treat ranging sequence and realize 100% covering.

Description

Towards the method for generating test case and device of equality constraint
Technical field
The invention belongs to software testing technology field, more particularly, to a kind of Test cases technology side towards equality constraint Method and device.
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.
In numerous method for testing software, the Test cases technology process of path-oriented can be described as:It is given one Any one paths (hereinafter referred to as W) in program module (hereinafter referred to as P) and P, a variable (hereinafter referred to as xi) if there is In one of P input statement, then xi is referred to as a P input variable, and xi domain (hereinafter referred to as Dxi) is that xi is all can The value set of energy.One input vector x={ x1, x2 ..., xm } ∈ (Dx1 × Dx2 × ... × Dxm) it is referred to as a P program Input, referred to as the one of P input, wherein m are the number of input variable in P.If P all input datas are expressed as solution space D, seek x ∈ D so that run P along W using x as input.At present path W Test cases technology mainly manually completing, it is necessary to The substantial amounts of time.
At present, with the presence of a large amount of equality constraints in tested program, if mainly by being accomplished manually, of long duration, efficiency is low, and If it can not meet equality constraint the test case ultimately generated can be caused to be unable to reach 100% coverage rate, so as to be difficult to meet Requirement for software reliability.
The content of the invention
The present invention provides a kind of method for generating test case and device towards equality constraint, to overcome in the prior art During tested program generation test case comprising equality constraint, of long duration, the problem of efficiency is low.
The invention provides a kind of method for generating test case towards equality constraint, including:Receive Test cases technology Request, program to be measured is carried in the generation request;
Obtain each variable in the predefined paths, expression list, the predefined paths of the program to be measured and each First interval of variable;
According to the equation in the expression list, the first coefficient matrix and the first augmented matrix of equality constraint are determined;
Judge whether the order of first coefficient matrix is less than the order of first augmented matrix;
If it is not, then carrying out rollback computing to each variable, the second interval of each variable is determined;
Judge whether the boundary value of the second interval of each variable is equal;
If equal, test case is generated according to the second interval of each variable.
The invention provides a kind of Test cases technology device towards equality constraint, including:
Receiving module, for receiving Test cases technology request, program to be measured is carried in the generation request;
Acquisition module, it is each in the predefined paths, expression list, the predefined paths for obtaining the program to be measured First interval of individual variable and each variable;
Determining module, for the equation in the expression list, determine equality constraint the first coefficient matrix and First augmented matrix;
Judge module, for judging whether the order of first coefficient matrix is less than the order of first augmented matrix;
Computing module, for if it is not, then carry out rollback computing to each variable, determining the second value of each variable Section;
The judge module, it is additionally operable to judge whether the boundary value of the second interval of each variable is equal;
Generation module, if for equal, test case is generated according to the second interval of each variable.
Method for generating test case and device provided by the invention towards equality constraint, it is medium by constructing program to be measured The coefficient matrix and augmented matrix of formula constraint, when it is determined that the order of coefficient matrix is more than augmented matrix, are treated each in ranging sequence The interval of individual variable carries out rollback computing, and the interval then not conflicted according to the rollback computing of each variable is given birth to Into test case, the process of test case is generated without manual intervention, speed is fast, efficiency high, can treat ranging sequence and realize 100% Covering.
Brief description of the drawings
Fig. 1 is the flow chart of the method for generating test case embodiment one provided by the invention towards equality constraint;
Fig. 2 is the flow chart of the method for generating test case embodiment two provided by the invention towards equality constraint;
Fig. 3 is the schematic flow sheet of the second interval provided by the invention for determining all variables;
Fig. 4 is the structural representation of the Test cases technology device embodiment one provided by the invention towards equality constraint;
Fig. 5 is the structural representation of the Test cases technology device embodiment two provided by the invention towards equality constraint.
Embodiment
Fig. 1 is the schematic flow sheet of the method for generating test case embodiment one provided by the invention towards equality constraint. As shown in figure 1, it should include towards the method for generating test case of equality constraint:
S100, Test cases technology request is received, program to be measured is carried in the generation request.
The executive agent of this method for generating test case is Test cases technology device.What Test cases technology device received Test cases technology is asked, and can be triggered after program to be measured is received;Can also be obtained in Test cases technology device After program to be measured, by manually by triggering the triggering of the Test cases technology button in Test cases technology device, the present invention This is not limited.
S101, obtain the predefined paths of the program to be measured, expression list, each variable in the predefined paths and First interval of each variable.
After Test cases technology device receives program to be measured, treat ranging sequence and analyzed, read the pre- of program to be measured Determine path, and generate the controlling stream graph of program to be measured.And then the controlling stream graph by traveling through program to be measured is obtained in predefined paths Each variable, the interval and expression list etc. of each variable.
Specifically, traveling through controlling stream graph first, the node containing expression formula is extracted, and is stored in linear list row.Then Each node in linear list is traveled through, extracts variable and expression formula.
By traveling through each node in linear list, expression formula in conditional statement and variable are extracted, wherein, table It is used for the calculating of condition, operation object of the variable as subsequent searches process up to formula.This process can contain along said extracted Have the path of the node of expression formula to carry out, during it is also contemplated that assignment statement on path.Some conditions can be uniquely Determine the value of some or some variables.And these implicit values are the same just as assignment, it is no longer necessary to search further for.This can be with Search space is reduced significantly.This condition will be calculated preferentially.For example, conditional statement:If (a==3), now, preferentially The sentence is calculated, the valued space that can determine variable a quickly can only be just { 3 }.
A search principle is that finite region is preferential derived from the above-mentioned strategy for preferentially calculating the condition that can uniquely determine value 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 searched for successfully.For example, it is assumed that x is an integer variable, condition Sentence if (1≤x≤3), it is determined that x ∈ [1,2,3].
Global variable and static variable that variable generally includes to use in function parameter, function are originally inputted, is passed through first Ergodic abstract syntax tree, identify 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 domain of variable is originally inputted by type of variables and operating system environment It has been determined that, the restriction scope of assignment and conditional statement in calculation procedure, it is further to the valued space that is originally inputted variable Compression.It is final to determine each input variable interval of path end node.
The form for defining expression formula is the form of similar mathematic(al) representation, such as tested program
It is { x1+x2+x3=100, x1-x2-x3=10 } that the expression list of extraction, which includes,.
S102, according to the equation in the expression list, determine the first coefficient matrix and the first augmentation of equality constraint Matrix.
For example, in the above example, the first coefficient matrices A of extraction and the first augmented matrix B are respectively:
And
S103, judges whether the order of first coefficient matrix is less than the order of first augmented matrix.
S104, if it is not, then carrying out rollback computing to each variable, determine the second interval of each variable.
Specifically, the order R (A)=2 of above-mentioned matrix A, order R (B)=2, R (A)=R (B), the i.e. order of matrix A of matrix B is not Less than the order of matrix B.Then determine that above-mentioned predefined paths are reachable, then can carry out rollback fortune to the interval of above-mentioned each variable Calculate.Rollback computing is carried out to the interval of each variable, refers to that be followed successively by each variable takes in interval corresponding to each variable It is worth assignment, then the Ingress node by the value of each variable for people's program control flowchart to be measured, traversal controlling stream graph are carried out successively Interval arithmetic.
Accordingly, if by judging to determine that the order of the coefficient matrix of equality constraint in program to be measured is less than augmented matrix Order, then it can determine that the predefined paths are unreachable, you can terminate the generation of the test case.Infeasible paths refer to defeated what is given Enter in section, the path is may to be never performed.
Analysis shows, substantial amounts of infeasible paths be present in general program.During test case is produced, selection Infeasible paths are possible, and this is also one of principal element for influenceing testing efficiency, therefore should be stopped as early as possible to the path Calculating, exit Test cases technology process.
S105, judge whether the boundary value of the second interval of each variable is equal.
S106, if equal, test case is generated according to the second interval of each variable.
Specifically, when carrying out rollback computing for the interval of each variable, if controlling stream graph can reach program termination Node, illustrate that the rollback computing of the fallback value of the variable does not conflict, then the border of the interval of the variable can be set to Section using the fallback value as up-and-down boundary, for example, if the first interval of shaping variable X is [1,10], to variable X When carrying out rollback computing, when variable X is entered as into 6, the Ingress node of program control flowchart to be measured is substituted into, by traveling through controlling stream For figure up to program termination node, then the second interval that can temporarily determine variable X is [6,6].When having traveled through all variables Afterwards, then judge all variables interval border it is whether equal, if all equal, illustrate that all variables have all carried out section Computing, you can test case is generated according to the second interval of all variables, by the institute in the test case that now generates The interval for having variable passed rollback computing, so the test case can treat ranging sequence and realize 100% covering.
The method for generating test case towards equality constraint that the present embodiment provides, by constructing in program to be measured equation about The coefficient matrix and augmented matrix of beam, when it is determined that the order of coefficient matrix is more than augmented matrix, treat each change in ranging sequence The interval of amount carries out rollback computing, and the interval then not conflicted according to the rollback computing of each variable, which generates, to be surveyed Example on probation, generates the process of test case without manual intervention, speed is fast, efficiency high, can treat ranging sequence and realize that 100% covers Lid.
Fig. 2 is the schematic flow sheet of the method for generating test case embodiment two provided by the invention towards equality constraint. As shown in Fig. 2 it should include towards the method for generating test case of equality constraint:
S200, Test cases technology request is received, program to be measured is carried in the generation request.
S201, obtain the predefined paths of the program to be measured, expression list, each variable in the predefined paths and First interval of each variable.
S202, according to the equation in the expression list, determine the first coefficient matrix and the first augmentation of equality constraint Matrix.
S203, judges whether the order of first coefficient matrix is less than the order of first augmented matrix, if it is not, then performing S204, if so, then performing 210.
S204, rollback computing is carried out to each variable, determines the second interval of each variable.
Specifically, Fig. 3 is the schematic flow sheet of the second interval of each variable of determination that the present embodiment provides.Such as figure Shown in 3, above-mentioned S204 includes:
S301, each variable is ranked up according to the first default rule, determines current variable.
Specifically, the first default rule can be the number occurred according to variable in expression formula, or the area of variable Between size etc., the present embodiment is not limited this.
S302, judges whether the variable number in the expression list in all equatioies is both less than 3, if so, then holding Row S303, otherwise, perform S316
I.e. peer-to-peer takes " laziness solves " strategy, and just S303 is used to it only when having two variables in equation In climbing method solved, be otherwise only made whether the judgement of solution, can so reduce step S316 operand.
S303, it is that the current variable chooses the first fallback value according to climbing method fallback value selection rule.
Fallback value is selected for current variable, now it is equal to be expressed as bound shaped like [V, V] for the section of current variable Section, and the section of its dependent variable (having retracted and not retracting) be to maintain it is constant, i.e., it is unique apart from last time rollback computing What is changed is exactly that the section of current variable becomes a determination value from a bounded interval.
S304, yojan is carried out to first coefficient matrix and the first augmented matrix, determines the second coefficient matrix and second Augmented matrix.
To be the first fallback value that current variable is chosen in people's equation set, each equation is subjected to abbreviation, it is then determined that The second coefficient matrix and the second augmented matrix of equation after abbreviation.For example, it is { x1+x2+ that above-mentioned expression list, which includes, X3=100, x1-x2-x3=10 }, if current variable is x2, the first fallback value that x2 chooses is 5, the expression list after abbreviation For { x1+x3=95, x1-x3=15 }.Accordingly, the second coefficient matrix obtained isSecond augmented matrix is
S305, judges whether the order of second coefficient matrix is less than the order of second augmented matrix, if it is not, then performing S306, if so, then performing S314.
S306, rollback computing is carried out to the current variable.
Rollback computing is carried out to the first fallback value of current variable, i.e., by the border of current variable equal interval generation The Ingress node of people's program control flowchart, carry out interval arithmetic.
S307, judges whether the rollback computing of the current variable conflicts, if so, then performing S310, otherwise, performs S308。
S308, judge whether to have carried out rollback computing to all variables, if so, then performing S309, otherwise, perform S317。
S309, determine the second interval of all variables.
S310, judge whether to have traveled through all fallback values of current variable, if so, 312 are then performed, if it is not, then performing S311。
S311, the second fallback value is chosen for the current variable, returns and performs S306.
Specifically, by analyzing contradictory information, however, it is determined that the first fallback value of current variable is chosen it is less than normal, The second fallback value can be then chosen between the first fallback value and the upper boundary values of the interval of current variable, however, it is determined that become to current First fallback value of amount is chosen bigger than normal, then can be chosen between the first fallback value and the lower border value of the interval of current variable Second fallback value.
S312, judge whether to carry out trace-back operation to current variable, if so, S318 is then performed, if it is not, then performing S313。
S313, trace-back operation is carried out to the current variable, and the 3rd fallback value is chosen for the current variable, return is held Row S306.
Specifically, carrying out trace-back operation to current variable, refer to according to the above-mentioned result being ranked up for all variables, from The previous variable of current variable is chosen in the variable of sequence, the present invention is referred to as previous variable, is re-started back for previous variable Computing is moved back, chooses new fallback value, on the basis of the new fallback value of previous variable, chooses fallback value again for current variable, Again rollback computing is carried out to the fallback value of current variable.
It should be noted that before S313 is performed, in addition to:Judge whether current variable is in variables reordering queue First variable, if, it is determined that the Program Generating test case failure to be measured, if it is not, then performing S313.
During the i.e. above-mentioned progress trace-back operation to current variable, if current variable is traveling through all fallback values of previous variable Afterwards, still the variable previous again to previous variable can not can then be continued by rollback computing, the present invention is referred to as again returning for preceding variable Move back value to be traveled through, and on the basis of the new fallback value of preceding variable again, rollback computing is carried out to previous variable, then to current Variable carries out rollback computing, until the rollback computing of current variable, by rear, the latter variable for continuing current variable is retracted After all available fallback values of first variable in computing, or the sequencing queue up to tracing back to all variables, still there is variable Rollback computing can not be by then can determine that the Test cases technology failure of program to be measured.
S314, judge whether to have traveled through all fallback values of current variable, if so, S318 is then performed, if it is not, then performing S315。
S315, it is that the current variable chooses the 4th fallback value according to climbing method fallback value selection rule, is then based on institute The 4th fallback value is stated, performs S304.
It should be noted that the 4th fallback value is the different values with the first fallback value.
S316, it is that the current variable chooses the 5th fallback value according to the second default rule, is then based on the described 5th Fallback value performs S306.
Specifically, the second default rule can be from the interval of current variable choose median, minimum value or Person's maximum is not limited this as the 5th fallback value, the present embodiment.
S317, current variable is redefined, return and perform S302.
If, can as procedure described above again by judging that not treating all variables in ranging sequence carries out rollback computing Current variable is determined, and fallback value is chosen for current variable, continues rollback computing.Work as it should be noted that redefining During preceding variable, the result that can be ranked up according to above-mentioned S301 to variable, the variable of just having completed rollback computing is directly chosen Next variable is current variable, i.e., all variables in program to be measured turn into " current variable ", successively successively according to ranking results Carry out rollback computing.
S318, terminate.
S205, judge whether the boundary value of the second interval of each variable is equal, if equal, perform S206, otherwise return and perform S204.
S206, test case is generated according to the second interval of each variable.
S207, the program to be measured is driven with the test case of the generation, and record the actual execution of the program to be measured Path.
After use-case generation to be tested, test case can be verified, ranging can be treated with the test case driving of generation Sequence, and record execution route of the program to be measured under the driving of test case.
Specifically, also include before above-mentioned S207:
S207a, default code is inserted in the program to be measured.
Specifically, insert default code in tested software program, to obtain the information of program behavior when executed, Above-mentioned default code can be sentence.Inserting mainly determines to insert point according to controlling stream graph, in tested program controlling stream graph Beginning, bifurcation to tested program implement insert, then generate abstract syntax tree on inserting sentence tree node, then will take out As syntax tree changes output as source program again.
For example, following procedure:
After automatic inserting shaped like:
During tested program is performed, it is possible to the actual routing information performed of collection procedure.
Accordingly, above-mentioned S207 includes:
The program to be measured is driven with the test case of the generation;
The actual path performed of the program to be measured is recorded according to the pre-set code of the inserting.
It should be noted that the order between S207a and above-mentioned S201~S206 in the present embodiment is not unique.It can hold Go after S200, be carried out S207a, or S207a, the present embodiment are performed in any one step between having performed S201~S206 This is not limited.
S208, judges whether the actual execution route meets with predefined paths, if meeting, performs S209, otherwise holds Row S210.
S209, export test case.
Specifically, inserting code above have recorded actual execution route, it is contrasted with predetermined path, if The actual execution route of record meets with predetermined path, then illustrates that test case is correct, you can export test case to use Family.Accordingly, if not meeting, the test case for illustrating to obtain can not cover path to be measured it is necessary to regenerate, and this is due to Caused by some simplification approximate calculation during Test cases technology.
S210, terminate.
The method for generating test case towards equality constraint that the present embodiment provides, by constructing in program to be measured equation about The coefficient matrix and augmented matrix of beam, when it is determined that the order of coefficient matrix is more than augmented matrix, treat each change in ranging sequence The interval of amount carries out rollback computing, and the interval then not conflicted according to the rollback computing of each variable, which generates, to be surveyed Example on probation, generates the process of test case without manual intervention, speed is fast, efficiency high, can treat ranging sequence and realize that 100% covers Lid.And drive program to be measured using the test case of generation, it is ensured that the test case of generation drives the actual road of program to be measured Footpath meets with predefined paths, further increases the reliability of the test case of generation.
Fig. 4 is the structural representation of the Test cases technology device embodiment one provided by the invention towards equality constraint. As shown in figure 4, the Test cases technology device 400, including:Receiving module 401, acquisition module 402, determining module 403, judgement Module 404, computing module 405 and generation module 406.
Wherein, receiving module 401, for receiving Test cases technology request, program to be measured is carried in the generation request; Acquisition module 402, each change in predefined paths, expression list, the predefined paths for obtaining the program to be measured First interval of amount and each variable;Determining module 403, for the equation in the expression list, it is determined that etc. The first coefficient matrix and the first augmented matrix of formula constraint;Judge module 404, for judging that the order of first coefficient matrix is The no order less than first augmented matrix;Computing module 405, for if it is not, then carry out rollback computing to each variable, Determine the second interval of each variable;The judge module 404, it is additionally operable to judge the second value area of each variable Between boundary value it is whether equal;Generation module 406, if for equal, given birth to according to the second interval of each variable Into test case.
The device of the present embodiment can be used for the technical scheme for performing embodiment of the method shown in Fig. 1, its realization principle and skill Art effect is similar, and here is omitted.
Fig. 5 is the structural representation of the Test cases technology device embodiment two provided by the invention towards equality constraint. As shown in figure 5, the Test cases technology device 500, on the basis of shown in Fig. 4, in addition to:Drive module 501.
Wherein, drive module 501, the program to be measured is driven with the test case of the generation, and recorded described to be measured The actual path performed of program;Accordingly, judge module 404, it is additionally operable to judge that the actual execution route is with predefined paths It is no to meet;Determining module 403 is additionally operable to, if meeting, it is determined that test case is correct.
Further, in addition to:Module 502 is inserted, for inserting default code in the program to be measured;The drive Dynamic model block 501 is specifically used for driving the program to be measured with the test case of the generation;According to the pre-set code of the inserting Record the actual path performed of the program to be measured.
Further, the computing module, is specifically used for:
Each variable is ranked up according to the first default rule, determines current variable;
Judge whether the variable number in the expression list in all equatioies is both less than 3;
If so, it is then that the current variable chooses the first fallback value according to climbing method fallback value selection rule;
According to first fallback value, yojan is carried out to first coefficient matrix and the first augmented matrix, determines second Coefficient matrix and the second augmented matrix;
Judge whether the order of second coefficient matrix is less than the order of second augmented matrix;
If it is not, rollback computing then is carried out to the current variable;
Judge whether the rollback computing of the current variable conflicts;
If it is not, then judge whether to carry out rollback computing to all variables;
If, it is determined that the second interval of all variables.
In a kind of possible way of realization of the present invention, the computing module, also particularly useful for:
If not, it is determined that new current variable, the process of second interval for determining all variables is repeated, Until determine the second interval of all variables.
In another possible way of realization of the present invention, the computing module, also particularly useful for:
If so, then judge whether to have traveled through all fallback values of the current variable;
If it is not, then choosing the second fallback value for the current variable, and second fallback value is based on, entered for current variable Row rollback computing, until having traveled through all fallback values of the current variable.
In the alternatively possible way of realization of the present invention, the computing module, also particularly useful for:
If so, then judge whether to carry out trace-back operation to the current variable;
If it is not, trace-back operation then is carried out to the current variable;
The 3rd fallback value is chosen for the current variable, the current variable is retracted based on the 3rd fallback value Computing.
In another possible way of realization of the present invention, the computing module, also particularly useful for:
If so, then judge whether to have traveled through all fallback values of the current variable;
If it is not, it is then that the current variable chooses the 4th fallback value according to climbing method fallback value selection rule;
According to first fallback value, repeat and yojan carried out to first coefficient matrix and the first augmented matrix, Determine the second coefficient matrix and the second augmented matrix.
In another possible way of realization of the present invention, the computing module, also particularly useful for:
If it is not, it is then that the current variable chooses the 5th fallback value according to the second default rule;
Based on the 5th fallback value, to carry out rollback computing to the current variable.
The device of the present embodiment can be used for perform Fig. 2 and 3 shown in embodiment of the method technical scheme, its realization principle and Technique effect is similar, and here is omitted.
One of ordinary skill in the art will appreciate that:Realizing all or part of step of above method embodiment can pass through Programmed instruction related hardware is completed, and foregoing program can be stored in a computer read/write memory medium, the program Upon execution, the step of execution includes above method embodiment;And foregoing storage medium includes:ROM, RAM, magnetic disc or light Disk etc. is various can be with the medium of store program codes.
Finally it should be noted that:Various embodiments above is merely illustrative of the technical solution of the present invention, rather than its limitations;To the greatest extent The present invention is described in detail with reference to foregoing embodiments for pipe, it will be understood by those within the art that:Its according to The technical scheme described in foregoing embodiments can so be modified, either which part or all technical characteristic are entered Row equivalent substitution;And these modifications or replacement, the essence of appropriate technical solution is departed from various embodiments of the present invention technology The scope of scheme.

Claims (9)

  1. A kind of 1. method for generating test case towards equality constraint, it is characterised in that including:
    Test cases technology request is received, program to be measured is carried in the generation request;
    Obtain each variable in the predefined paths, expression list, the predefined paths of the program to be measured and each variable The first interval;
    According to the equation in the expression list, the first coefficient matrix and the first augmented matrix of equality constraint are determined;
    Judge whether the order of first coefficient matrix is less than the order of first augmented matrix;
    If it is not, then carrying out rollback computing to each variable, the second interval of each variable is determined;
    Judge whether the boundary value of the second interval of each variable is equal;
    If equal, test case is generated according to the second interval of each variable;
    Wherein, second interval for determining each variable, including:
    Each variable is ranked up according to the first default rule, determines current variable;
    Judge whether the variable number in the expression list in all equatioies is both less than 3;
    If so, it is then that the current variable chooses the first fallback value according to climbing method fallback value selection rule;
    According to first fallback value, yojan is carried out to first coefficient matrix and the first augmented matrix, determines the second coefficient Matrix and the second augmented matrix;
    Judge whether the order of second coefficient matrix is less than the order of second augmented matrix;
    If it is not, rollback computing then is carried out to the current variable;
    Judge whether the rollback computing of the current variable conflicts;
    If it is not, then judge whether to carry out rollback computing to all variables;
    If, it is determined that the second interval of all variables.
  2. 2. the method for generating test case according to claim 1 towards equality constraint, it is characterised in that the generation is surveyed After example on probation, in addition to:
    The program to be measured is driven with the test case of the generation, and records the actual path performed of the program to be measured;
    Judge whether the actual execution route meets with predefined paths;
    If meet, it is determined that test case is correct.
  3. 3. the method for generating test case according to claim 2 towards equality constraint, it is characterised in that described in the use The test case of generation drives the program to be measured, and before recording the actual path performed of the program to be measured, in addition to:
    Default code is inserted in the program to be measured;
    The test case with the generation drives the program to be measured, and records and state the actual path performed of program to be measured, Including:
    The program to be measured is driven with the test case of the generation;
    The actual path performed of the program to be measured is recorded according to the pre-set code of the inserting.
  4. 4. the method for generating test case according to claim 1 towards equality constraint, it is characterised in that the judgement is It is no rollback computing is carried out to all variables after, in addition to:
    If not, it is determined that new current variable, the process of second interval for determining all variables is repeated, until Determine the second interval of all variables.
  5. 5. the method for generating test case according to claim 1 towards equality constraint, it is characterised in that the judgement institute State current variable rollback computing whether conflict after, in addition to:
    If so, then judge whether to have traveled through all fallback values of the current variable;
    If it is not, then choosing the second fallback value for the current variable, and second fallback value is based on, is returned for current variable Computing is moved back, until having traveled through all fallback values of the current variable.
  6. 6. the method for generating test case according to claim 5 towards equality constraint, it is characterised in that the judgement is After the no all fallback values for having traveled through the current variable, in addition to:
    If so, then judge whether to carry out trace-back operation to the current variable;
    If it is not, trace-back operation then is carried out to the current variable;
    The 3rd fallback value is chosen for the current variable, rollback fortune is carried out to the current variable based on the 3rd fallback value Calculate.
  7. 7. the method for generating test case according to claim 1 towards equality constraint, it is characterised in that the judgement institute Whether the order for stating the second coefficient matrix is less than after the order of second augmented matrix, in addition to:
    If so, then judge whether to have traveled through all fallback values of the current variable;
    If it is not, it is then that the current variable chooses the 4th fallback value according to climbing method fallback value selection rule;
    According to first fallback value, repeat and yojan is carried out to first coefficient matrix and the first augmented matrix, it is determined that Second coefficient matrix and the second augmented matrix.
  8. 8. the method for generating test case according to claim 1 towards equality constraint, it is characterised in that the judgement institute State whether the variable number in expression list in all equatioies is both less than after 3, in addition to:
    If it is not, it is then that the current variable chooses the 5th fallback value according to the second default rule;
    Based on the 5th fallback value, to carry out rollback computing to the current variable.
  9. A kind of 9. Test cases technology device towards equality constraint, it is characterised in that including:
    Receiving module, for receiving Test cases technology request, program to be measured is carried in the generation request;
    Acquisition module, each change in predefined paths, expression list, the predefined paths for obtaining the program to be measured First interval of amount and each variable;
    Determining module, for the equation in the expression list, determine the first coefficient matrix and first of equality constraint Augmented matrix;
    Judge module, for judging whether the order of first coefficient matrix is less than the order of first augmented matrix;
    Computing module, for if it is not, then carry out rollback computing to each variable, determining the second value area of each variable Between;
    The judge module, it is additionally operable to judge whether the boundary value of the second interval of each variable is equal;
    Generation module, if for equal, test case is generated according to the second interval of each variable;
    Wherein, the computing module, is specifically used for:
    Each variable is ranked up according to the first default rule, determines current variable;
    Judge whether the variable number in the expression list in all equatioies is both less than 3;
    If so, it is then that the current variable chooses the first fallback value according to climbing method fallback value selection rule;
    According to first fallback value, yojan is carried out to first coefficient matrix and the first augmented matrix, determines the second coefficient Matrix and the second augmented matrix;
    Judge whether the order of second coefficient matrix is less than the order of second augmented matrix;
    If it is not, rollback computing then is carried out to the current variable;
    Judge whether the rollback computing of the current variable conflicts;
    If it is not, then judge whether to carry out rollback computing to all variables;
    If, it is determined that the second interval of all variables.
CN201510229658.4A 2015-05-07 2015-05-07 Towards the method for generating test case and device of equality constraint Expired - Fee Related CN104809067B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510229658.4A CN104809067B (en) 2015-05-07 2015-05-07 Towards the method for generating test case and device of equality constraint

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510229658.4A CN104809067B (en) 2015-05-07 2015-05-07 Towards the method for generating test case and device of equality constraint

Publications (2)

Publication Number Publication Date
CN104809067A CN104809067A (en) 2015-07-29
CN104809067B true CN104809067B (en) 2017-11-17

Family

ID=53693909

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510229658.4A Expired - Fee Related CN104809067B (en) 2015-05-07 2015-05-07 Towards the method for generating test case and device of equality constraint

Country Status (1)

Country Link
CN (1) CN104809067B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105224455B (en) * 2015-09-28 2018-01-09 北京邮电大学 A kind of method for automatically generating character string type test case
CN106681903B (en) * 2015-11-11 2020-05-12 阿里巴巴集团控股有限公司 Method and device for generating test case
US9792204B2 (en) * 2016-02-02 2017-10-17 General Electric Company System and method for coverage-based automated test case augmentation for design models
CN113238932B (en) * 2021-04-30 2024-03-19 西南电子技术研究所(中国电子科技集团公司第十研究所) Automatic test case generation method

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6986125B2 (en) * 2001-08-01 2006-01-10 International Business Machines Corporation Method and apparatus for testing and evaluating a software component using an abstraction matrix
CN103019934A (en) * 2012-11-28 2013-04-03 北京交控科技有限公司 Test case generation method based on data code separation technology
CN104317708A (en) * 2014-10-21 2015-01-28 北京邮电大学 Software testing case automatic generating method and system based on iterative interval arithmetic

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6986125B2 (en) * 2001-08-01 2006-01-10 International Business Machines Corporation Method and apparatus for testing and evaluating a software component using an abstraction matrix
CN103019934A (en) * 2012-11-28 2013-04-03 北京交控科技有限公司 Test case generation method based on data code separation technology
CN104317708A (en) * 2014-10-21 2015-01-28 北京邮电大学 Software testing case automatic generating method and system based on iterative interval arithmetic

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于分支限界搜索框架的测试用例自动生成;邢颖 等;《中国科学》;20141231;第44卷(第10期);第1345-1360页 *
测试用例自动生成的分支限界算法及实验研究;邢颖;《中国博士学位论文全文数据库 信息科技辑》;20150415(第4期);正文第85-89页 *

Also Published As

Publication number Publication date
CN104809067A (en) 2015-07-29

Similar Documents

Publication Publication Date Title
US6922829B2 (en) Method of generating profile-optimized code
CN104252408B (en) Method and device for providing test case
CN104809067B (en) Towards the method for generating test case and device of equality constraint
US6381739B1 (en) Method and apparatus for hierarchical restructuring of computer code
US5918037A (en) Generating tests for an extended finite state machine using different coverage levels for different submodels
EP1618470B1 (en) Method and apparatus for recovering data values in dynamic runtime systems
CN105138335B (en) A kind of function call path extraction method and device based on controlling stream graph
JP2005302028A (en) Method and system for probe optimization for instrumenting program
CN109086215B (en) Embedded software unit test case generation method and system
JP2011248895A (en) Software application profiling method and device
JPH04225431A (en) Method for compiling computer instruction for increasing instruction-cache efficiency
JP6904043B2 (en) Input discovery for unknown program binaries
CN108021507A (en) The parallel route searching method and device of semiology analysis
CN104965687B (en) Big data processing method and processing device based on instruction set generation
CN106462432A (en) Data-dependent control flow reduction
US7734559B2 (en) Rule processing method and apparatus providing exclude cover removal to simplify selection and/or conflict advice
KR101275727B1 (en) Method for reconstructing statement and computer system having the function therefor
James et al. Performance enhancements to tabu search for the early/tardy scheduling problem
CN110399284A (en) A kind of test case writes and executes method and device
US6718544B1 (en) User interface for making compiler tradeoffs
Cerrito et al. Using linear temporal logic to model and solve planning problems
CN104317708B (en) The software test case automatic generating method and system of the interval arithmetic based on iteration
CN110209593B (en) Preference setting-oriented android application testing method
KR101038397B1 (en) Method for determining test alternation factor in robot software white box test and automated testing system
CN106155898B (en) Method and device for acquiring path of flow chart

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
EXSB Decision made by sipo to initiate 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

Granted publication date: 20171117

CF01 Termination of patent right due to non-payment of annual fee