[go: up one dir, main page]

CN102176200A - Software test case automatic generating method - Google Patents

Software test case automatic generating method Download PDF

Info

Publication number
CN102176200A
CN102176200A CN2009100353676A CN200910035367A CN102176200A CN 102176200 A CN102176200 A CN 102176200A CN 2009100353676 A CN2009100353676 A CN 2009100353676A CN 200910035367 A CN200910035367 A CN 200910035367A CN 102176200 A CN102176200 A CN 102176200A
Authority
CN
China
Prior art keywords
model
stage
test case
petri net
analysis
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.)
Pending
Application number
CN2009100353676A
Other languages
Chinese (zh)
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.)
Nanjing University of Aeronautics and Astronautics
Original Assignee
Nanjing University of Aeronautics and Astronautics
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 Nanjing University of Aeronautics and Astronautics filed Critical Nanjing University of Aeronautics and Astronautics
Priority to CN2009100353676A priority Critical patent/CN102176200A/en
Publication of CN102176200A publication Critical patent/CN102176200A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

本发明公布了一种软件测试用例自动生成方法,属于软件测试自动化的技术领域。本发明所述方法包括如下步骤:1.第一阶段基于被测对象(这里考虑三类对象:结构化语言程序,基于需求或场景描述,面向对象程序)建立组件化Petri网模型;2.第二阶段用适当的数据结构收集和存储PN模型中库所、变迁的前集、后集以及初始化条件等模型结构的相关信息;3.第三阶段根据第二阶段收集的信息采用适当的算法对模型分析与验证(死锁、活性、有界性、可达性等);4.第四阶段测试用例生成;5.第五阶段按照不同覆盖率指标进行测试用例分析;6.第六阶段根据用户原始需求与质量要求,综合分析,重新生成符合要求的测试用例集。

Figure 200910035367

The invention discloses a method for automatically generating software test cases, belonging to the technical field of software test automation. The method of the present invention comprises the following steps: 1. the first stage is based on the measured object (considering three types of objects here: structured language program, based on requirements or scene description, object-oriented program) to set up a componentized Petri net model; 2. the first stage In the second stage, use an appropriate data structure to collect and store relevant information about the model structure such as places in the PN model, the pre-set and post-set of transition, and initialization conditions; 3. The third stage adopts appropriate algorithms based on the information collected in the second stage Model analysis and verification (deadlock, liveness, boundedness, reachability, etc.); 4. Test case generation in the fourth stage; 5. Test case analysis in the fifth stage according to different coverage indicators; 6. The sixth stage is based on The user's original needs and quality requirements are comprehensively analyzed to regenerate a set of test cases that meet the requirements.

Figure 200910035367

Description

A kind of software test case automatic generating method
Technical field
Invention relates to a kind of method that generates automatically based on the software test case of Petri net, belongs to the technical field of software test automation.
Background technology
Software test is an important means that guarantees the software systems correctness, and it finds mistake in the software by moving selected test case, and makes the quality of software reach requirement by correcting a mistake.The key issue of software test is exactly the reasonable and limited set of a test case of structure, covers the problem space of tested software as much as possible.Being created on of software test data occupies very big proportion in software system development time and the expense, and the artificial choosing method workload that mainly adopts at present is big, test period long, occur omission easily, and effectiveness is low, can realize very high value being arranged automatically if therefore there is method to allow this choose process to generate the high test use cases of effectiveness.
Genetic algorithm is the optimized Algorithm of simulation biological evolution, and utilizing genetic algorithm to generate software test case is an important branch of software test case automatic generating method.The D.Berndt of University of SouthFlorida, J.Fisher has studied the technology that generates software test case with genetic algorithm in great detail on the basis of summing up forefathers.The golden tiger of Sichuan University has been adopted the method for generating test case towards the path, use genetic algorithm equivalent partition is carried out in the test case space, dynamically adjust test case according to fitness and generate, instruct test case to generate by evolutionary computation to reduce the test redundancy.As document: (1) D.Berndt, J.Fisher, L.Johnson *, J.Pinglikar, and A.Watkins.Breeding Software Test Cases with Genetic Algorithms[J]. Proceedings of the 36 ThHawaii International Conference on SystemSciences.2003 (2) Jin Hu. generate [J] automatically based on test case towards the genetic algorithm in path. computer engineering .2007
Test based on UML is an object-oriented software Research of measuring focus.Kim Y K, Hong H S, Bae D H just was applied to the UML constitutional diagram in the automatic generation of test case as far back as 1999, a kind of generation method based on the test case of the class of UML constitutional diagram that control stream and data stream are combined has been proposed, make UML obtain unification in object-oriented modeling and test, lot of domestic and international experts and scholars have proposed expansion to this method.The Zhang Yikun of Xi'an University of Technology combines the constitutional diagram based on the class of the unique input and output UIO automatic example generation method of the finite state machine EFMS of expansion and UML, has proposed a kind of automatic example generation method of the class based on the UML constitutional diagram.The characteristics of this method are to have comprised prediction in test case, guarantee that by algorithm the length of test case is the shortest, test simultaneously from constitutional diagram, have avoided the state explosion problem that occurs in the modeling.As document: (1) Kim Y K, Hong HS, Bae D H.Test Cases Generation From UML State Diagrams[J] .IEEEProc.Softw..1999 (2) Zhang Yikun, Shi Fengming, Yao Quanzhu, Liu Jun pays long queue. based on the class testing case automatic generating method [J] of UML constitutional diagram. and computer engineering .2003
In existing software test case automatic generating method, generally still more or less have the following disadvantages:
(1) can only test at the software of certain single type, for example object-oriented program, perhaps structured program;
(2) target program that is used to generate test case must at first will have specific implementation, promptly has program that test case is just arranged earlier;
(3) concrete rule criterion is not set up in the collection of institute's established model structural information, causes being unfavorable for the analysis and the checking of model;
(4) institute's established model does not have clear and definite evaluation mechanism, and promptly the rationality of model itself does not have method evaluation, directly influences the effectiveness of test case;
(5) the artificial step that participates in is too many, and needs more relevant professional knowledge can implement correlation method;
(6) test case that obtains does not have more perfect evaluation mechanism.Traditional method is continued to use in the test case coverage rate analysis more under the new model, and index is more single, can not comprehensively reflect the quality of software;
(7) test case management mechanism lacks, and according to the performance evaluation of test case and revised content in time is not reflected to test case and concentrates, and does not reach progressively optimization effect.
Summary of the invention
The present invention seeks to provides a kind of software test case automatic generating method at the defective that art methods exists.
The present invention is a kind of software test case automatic generating method, it is characterized in that comprising the steps:
1.) phase one is set up modularization Petri pessimistic concurrency control according to measurand:
(1) if program is structured program such as C language, because fixedly syntax format is arranged: sequential organization, construction of condition (if, switch), loop structure (while, for), then to structure modeling respectively, the Petri pessimistic concurrency control is exactly the combination of these modules; (2) if program is 00 program such as C++, generate transition model by the constitutional diagram of half formalization language UML, dynamic figure etc., be converted into the Petri pessimistic concurrency control by uml diagram again; (3) requirement description or scene directly generate the Petri pessimistic concurrency control;
2.) subordinate phase is collected Petri web frame information: each element (storehouse institute, transition, directed arc, Token etc.) of Petri pessimistic concurrency control is showed with the modularization form.Collect the information of various elements, promptly obtain the structural information of Petri net: the Qian Ji of storehouse institute, transition, back collection and initialization condition etc.;
3.) phase III model analysis and checking: the structural information of utilizing subordinate phase to obtain, in conjunction with model characteristics such as the deadlock of analyzing the Petri pessimistic concurrency control by the theoretical respective algorithms that generates of Petri net, activity, boundedness, accessibilities.Find that mistake then needs to get back to phase one modification model;
4.) the quadravalence section generates test case: the analytical approach with the set of reachable markings of Petri net is analyzed model, with depth-first or BFS (Breadth First Search) algorithm identifier is searched for and obtained to reachability tree or coverage diagram, to obtaining cycle tests arrangement generation test use cases;
5.) five-stage is analyzed the effectiveness of the test case that the quadravalence section obtains: traditional analysis method and customizing method combine.Tradition white-box testing analytical approach such as statement covering, judgement covering, condition covering, condition criterion combination covering, the covering of many conditions and the covering of correction decision condition etc.; Petri net user-defined counter covers as sign covering, transition;
6.) the 6th stage was adjusted test use cases according to the analysis of five-stage, got back to five-stage after test case is added, deletes, revised and reanalysed, until satisfying user's original demands and quality requirements.
Description of drawings
Fig. 1: based on the automatic process flow diagram that generates of Petri net software test case
Embodiment
1.Petri net formalization definition
1.1.Petri the sufficient and necessary condition of net
Tlv triple N=(S, T; F) sufficient and necessary condition that is called direct net (abbreviation net) is:
Figure G2009100353676D00041
Figure G2009100353676D00042
( 3 ) F ⊆ S × T ∪ T × S
(4) dom (F) ∪ cod (F)=S ∪ T, wherein:
dom ( F ) = { x | ∃ y : ( x , y ) ∈ F }
cod ( F ) = { y | ∃ x : ( x , y ) ∈ F }
S and T are called storehouse institute (place) and the transition (transition) of N, and F is a flow relation.
1.2. Qian Ji, Hou Ji
Qian Ji, back collection are inputing or outputing of T or S, and definition is arranged:
If x ∈ X is direct net N=(S, T; F) arbitrary element,
(1) (y, x) ∈ F} is called preceding collection (pre-set) or the input set of x to x={y.
(2) (x, z) ∈ F} is called back collection (post-set) or the output collection of x to x={z|.
1.3.S_ figure
If direct net N=is (S, T; F), if having
Figure G2009100353676D00051
N is called S_ figure.
1.4. capacity function, sign, weight function
To direct net N=(S, T; F), note N 0=0,1,2 ... }, and N={1,2,3 ... and represent infinite with ω: ω=ω+1=ω-1=ω+ω has:
(1) K:S → N ∪ { ω } is called the capacity function of N.
(2) to given capacity function K, M:S → N 0The condition that is called the sign of N is:
∀ s ∈ S : M ( s ) ≤ K ( s ) .
(3) W:F → N is called the weight function on the N, to (x, y) ∈ F, W (x, y)=((x, y)) is called (x, y) power on to W.
1.5. elementary net system and P/T system
(1)K≡1,W≡1。This time, S_ unit was called condition, and T_ unit is called incident, and the net system is called elementary net system (EN_ system).
(2)K≡ω,W≡1。Be called the P/T system.
Here, the difference of EN_ system and P/T system just is on the capacity of S_ unit that can think that the EN_ system is the special circumstances of P/T system when K is 1, the theory that is suitable for the P/T system is also suitable in the EN_ system.
2. workflow
Be elaborated below in conjunction with 1 pair of workflow of the present invention of accompanying drawing.
Software test case generation method based on the Petri net has following software test step:
2.1. the phase one (setting up modularization Petri pessimistic concurrency control) according to measurand
Comprising: (1) is if program is structured program such as C language, because fixedly syntax format is arranged: sequential organization, construction of condition (if, switch), loop structure (while, for), then modeling respectively, the Petri pessimistic concurrency control is exactly the combination of these modules; (2) if program is 00 program such as C++, generate transition model by the constitutional diagram of half formalization language UML, dynamic figure etc., be converted into the Petri pessimistic concurrency control by uml diagram again; (3) can directly generate the Petri pessimistic concurrency control for simple requirement description or scene.
Necessary and sufficient condition according to the Petri net draws the drafting criterion that Petri nets, and is summarized as follows:
(1) S is the different elements of two classes of direct net with T, uses different diagrammatic representations respectively.S represents with zero, and T is with (or-|) expression, and F is with oriented arrow → represent that Token represents information or resource, with representing;
(2) has an element in the net at least;
(3) F only occurs between T and the S, between T or the S inside flow relation can not take place;
(4) can not have isolated T or S in the net, promptly T or S must with the F effect.
The correct foundation of Petri pessimistic concurrency control is the precondition that correct analysis and test case generate.The necessary and sufficient condition that satisfies above Petri net has just been set up the model of Petri net.
2.2. subordinate phase (collecting Petri web frame information)
2.2.1.Petri web frame information storage means
It is information gathering of Petri net and basis of structural analysis that modularization thought is set up the Petri pessimistic concurrency control.Here assembly is exactly an object, and being reflected in the modeling tool is exactly the control that instantiation is come out, and is the encapsulation to data and method.Assembly has attribute, method, incident, the interface of oneself.Attribute is the easy access person of module data.Method then is some simple and visible functions of assembly.
Each element of Petri pessimistic concurrency control (storehouse institute, transition, directed arc, Token etc.) shows with the Componentized form.S in the model, T, F or Token etc. are the instantiations of associated component, and the uniqueness of oneself is all arranged, and use Property ID separately to identify, and comprising Qian Ji, Hou Ji, title, Token number etc. simultaneously again must attribute.Collect each attribute of an element information, promptly obtain the basic structure information of Petri net: the Qian Ji of storehouse institute, transition, back collection and initialization condition etc.
2.2.2. Petri pessimistic concurrency control characteristics based on scene
Most all is that Event triggered is come control flow based on model of place, and the characteristics of this model I are that model is S_ figure.
S_ figure means that the Qian Ji of arbitrary transition and back collection all are unique, (uses the storehouse represented, i.e. t owing to need definite result set after the concrete Event triggered ), the reason that simultaneous events triggers is (promptly T) determine also that these characteristics have determined the S_ figure characteristics of direct net N.
2.2.3. Petri pessimistic concurrency control abstract method based on scene
Node was too much when generally acknowledged shortcoming of Petri net was practical application, and leaving computer-aided tool just can not analytic system, and then the Petri net is visual and understandable, and the diagrammatic representation that is suitable for exchanging has lost meaning.Therefore need abstract model to reduce system node, thereby reach the effect of simplified model.
The first step, we define the principle of Petri pessimistic concurrency control node abstraction at the characteristics of S_ figure, and the realization details that promptly shields T_ unit masks, T_ unit T and t Still the directed arc with original direction connects, thereby has obtained only containing the digraph of S_ unit.The directed arc physical meaning has contained the transition incident among the figure as a result.
Second step, if do not need in the model analysis to understand the storehouse the realization details, then can have only the continuous S_ unit of single input and output directed arc to merge with 2 on above shielding principle basis, thereby reduce the node number of net system, be that following adjacency matrix analysis reduces burden.
We can obtain being used for the minimum model of analytic system node abstraction by above two steps, do not destroy the feature of Petri Netease in the descriptive system resource flow simultaneously again.Thereby, come the structural information of collection system with the net system model after simplifying.
2.2.4.Petri the data structure of web frame information
Storage organization to digraph in the net opinion has a lot of method for expressing, and commonly used have array representation (adjacency matrix), adjacency list, adjacency multilist and an orthogonal list.The representation of adjacency matrix has been represented the conversion of system library institute state more clearly, and the clear performance for the back cycle tests provides good method for expressing simultaneously, therefore selects adjacency matrix method for use.
2.3. the phase III (model analysis and checking)
The structural information of utilizing subordinate phase to obtain is in conjunction with model characteristics such as the deadlock of being analyzed the Petri pessimistic concurrency control by the theoretical respective algorithms that generates of Petri net, activity, boundedness, accessibilities.Find that mistake then needs to get back to phase one modification model.
There is different requirements in different systems to the Petri pessimistic concurrency control, just need write concrete algorithm to the specific (special) requirements of model and check various characteristics.Be the basic implementation method that example provides various character with model below based on scene.
2.3.1 set up the sign tree layout
Reachable marking tree is the basis of model analysis, but the reachable marking tree in the application of complication system at first demand side to being exactly the state explosion problem with what solve.Here we expand reachable marking tree analytical approach, set up the analytical approach of sign tree layout based on the reachable marking tree.
2.3.1.1 state explosion problem
The reachable marking tree is the tree represenation of all states of system, the accessibility between the expression state.The reachability tree representation is not perfectly, does not have perfect scheme at present on its state explosion problem of solution and provides.In the face of complication system, when needs traveled through all states, the state explosion problem had been limited to the traversal of reachability tree, and the shortcoming of the descriptive power scarcity of reachable marking tree comes out.Therefore primary is to limit the reachability tree scale within the specific limits.
2.3.1.2 the appearance main cause of state explosion problem
There are following two kinds: the one, there is the state variable of the excessive shaping type of codomain in the model, perhaps there is the quantity of state of the bigger shaping type of a plurality of codomains; The 2nd, there is the huge state variable of quantity in the model.
2.3.1.3 scheme thinking
This just requires us to define model effectively on functional structure, and that can not describe is too careful, and too careful model causes special topic to explode very much or increases the time of pattern checking.
Abstract and the simplification technology of model is exactly the method for good restraining state explosion.But model is abstract and simplify and can not solve the state explosion problem from the angle that initiatively suppresses, when model does not allow or system's merge node and the method for simplified model is worthless when need check all status informations.Here we adopt other method to cooperate the abstract and simplification technology of model, dwindle the model scale to greatest extent and do not influence system.
At model blast problem reason, there is following solution to consider.Will avoid the situation of M (s) ≠ 1 to occur in the time of at first will be from modeling, this point can be accomplished for the model based on scene.Reachability tree need be converted into overlay tree for the system of modeling difficulty and represent, i.e. the node that increases without limitation for path and sign, for example: ( 1,0,0 ) → a ( 1,1,0 ) → a ( 1,2,0 ) → a · · · , Each sign is all covered by successor marking on the path, and this node can merge representative with (1, w, 0).
2.3.1.4 expansion sign tree
Occur circulation when the structure problem of reachable marking tree itself makes our modeling and just can't give expression to model fully, and often there is the circulation of part of module in goal systems, the appearance of the ring of part of module makes the total system model increase rapidly and explosion phenomenon occurs just, needs us to define the sign tree (sign tree layout) of oneself.For the simplified system model, define several special joints:
Definition (1): jump out node (End Node)
System's ∑=(S, T; F, K, W, M 0),
Figure G2009100353676D00101
Then S_end is for jumping out node.
What jump out that node finishes is to jump out systemic circulation, and be designated as: S_end, S_end be the back collection not, does not promptly have successor node, and S_end comes down to dead marking, generally is used for jumping out system at any time and this being identified at based on often using in the model modeling of scene is set.
Definition (2): cyclic node (Loop Node)
System's ∑=(S, T arranged; F, K, W, M 0), set of reachable markings [ M 0 > , &Exists; M i &Element; [ M 0 > , 0 < i &le; n , 0 < j &le; n , If M is arranged i[t I+1>M I+1∧ M j[t J+1>M I+1, M then iBe cyclic node.
Sum up sign tree layout characteristics:
By start node, general node, jump out node, cyclic node is formed.
2. start from start node, end to jump out node.
3. there is one or several to flow substantially, expression standard Event stream.
4. finish BFS (Breadth First Search) by cyclic node, with basic stream supplemental tree.
5. be way flow, end to jump out node.
6. general is the node that can merge with node, adjacent and singly go into the same category node that singly goes out and merge.
7. tree is along laterally preferentially launching
8. can connect start node with jumping out node, form cyclic process, guarantee that all states can reach in the tree.
We utilize two category nodes of definition to improve the reachable marking tree, thereby have set up the sign tree layout based on the reachable marking tree.Owing to solved the infinite loop problem of model, utilized the sign tree layout just can solve the blast problem of state.Simultaneously, can utilize the part critical nature of sign tree layout analytic system, as activity, boundedness, accessibility etc.Provide concrete analysis below.
2.3.2 accessibility
Definition (accessibility):
If Petri net system ∑=(S, T arranged; F, K, W, M 0) and a sign M, there is M ∈ [M 0>then M is a reachable marking, if all can reach for all m ∈ M of ∑, just says that system's ∑ is to reach system.
Accessibility can be by the sign tree layout by leaf node M iUpwards review to search for whether can find initial marking M step by step to its father node 0Being divided into for two steps realizes that at first traversal sign tree layout finds all M iSign; Then, traversal M iAll nodes are upwards reviewed, by path if find M in the path, place 0M then iBe reachable marking.
//--the accessibility algorithm
FindFunc(v){
int Node[S_count];
int Flag=0;
NodeCopy (v, * Node[]); // obtain node Token collection
NodeFind(Node[]);
for(int i=0;i<Keep_count;i++){
Flag=NodeCmp(Node[]);
if(Flag)
Print (" M can reach ");
Else print (" M is unreachable ");
// search
NodeFind(Node[]){
for(int i=0;i<Node_count;i++){
Find (Node[i]); // relatively
Keep (i); // record
// relatively
int NodeCmp(Node[]){
for(int i=0;i<Root_count;i++){
if(Find(Node[i]));
Return 1;}}
2.3.3 it is active
Definition (activity):
To t ∈ T if to arbitrary reachable marking M ∈ [M 0>, all have the sign M ' ∈ that can reach from M [M>, make M ' [t>, then transition t is alive.If all t ∈ T are alive, just say system's ∑=(S, T; F, K, W, M 0) be alive.
Activity requires t can both carry out under all states, does not promptly have the state of being beyond one's reach, if all t all be live whole model is alive, also be circulation model.
System is not necessary for the requirement of activity, for example often needs a function that finishes or jump out system based on the model of scene, and this time, final sign M (end) was exactly a dead marking, because all can not be triggered by M (end) for t arbitrarily.Have this time two kinds of solutions to make the systemic circulation operation, allow system become system alive: a kind of is that M (end) is connected with T with M (0); Another kind is exactly to remove M (end) part.
In addition, it all is alive that system generally is not strict with each t, and it is alive perhaps just requiring the crucial t of part.Active t means that the operation of this part can carry out all the time, need set corresponding t to reachable marking like this and do specific Algorithm Analysis and judge its activity.We provide the activity that two theorems are judged concrete t.
Theorem (active theorem):
T only collects M2 behind collection M1 and one before corresponding one, if a T is that the inevitable M2 that lives can reach, promptly can be judged the activity of T by the accessibility of M2.Have necessary and sufficient condition and adequate condition as follows:
Necessary and sufficient condition: a. contains in all paths of this M2 will comprise all M; B. other nodes in the above-mentioned path, all paths at each node place have one jumping out node and will link to each other with M0 at least.
Adequate condition: jumping out node and will link to each other in all these paths with M0.
According to active theorem, can judge whether a concrete t is alive.
2.3.4 boundedness,
Definition (boundedness):
For all M ∈ [M 0>, there is positive integer k, make that M (s)≤k just says P/T_ system ∑=(S, T to all s ∈ S; F, K, W, M 0) be the system of bounded.Be also referred to as security system during k=1.
Boundedness represents that certain state is to want timely response events to handle in based on the system model of scene, and the situation of instructing and not carrying out can not occur receiving.
The reachable marking tree is the set of various states (set of reachable markings), can travel through the value condition that whole reachability tree is judged M (s) after the foundation, here can adopt the ergodic algorithm of depth-first, travel through the identification nodes of all Petri nets, read the concentrated Token number of Token that writes down in the node, compare with 1 simultaneously.
The algorithm of the node processing function in the traversal:
//--the node processing function
VisitFunc(v){
int Node[S_number];
NodeCopy (v, * Node[]); // obtain node Token collection
NodeCmp(Node[]);}
NodeCmp(Node[]){
for(int i=0;i<S_number;i++){
Cmp (Node[i]); // relatively
Keep (i); // record
2.4. quadravalence section (generation test case)
Analytical approach with the set of reachable markings of Petri net is analyzed model,, does arrangement and generates test use cases obtaining cycle tests to reachability tree or coverage diagram search and obtain identifier with depth-first or BFS (Breadth First Search) algorithm.
The main foundation of the generation of test case is exactly to identify tree layout.Use-case generates the branch following several stages and progressively generates.
1) first step, traversal sign tree layout obtains the shortest path of forward direction and is main path, and sign tree layout main path has covered all reachable markings.This has obtained the test use cases in first stage.
2) second step, the cyclic node of sign tree layout is that infinite loop begins, if each sign can be pointed to other paths again in other loop bodies in loop body, has therefore constituted very complicated test case sequence.Divide three kinds of situations:
A. initial cycle body-internal-circulation
B. many interior unidirectional circulations of loop body
C. many interior unordered circulations of loop body
For this a part of algorithm, define 3 parameter a, b, c and indicate 3 kinds of situations.
1) for the sign tree that does not have cyclic node, the path is limited, and the cycle tests number equals to jump out the number of node.
2) for the sign tree that has cyclic node, the path is unlimited, round-robin number of times multipath more is complicated more, so (parameter a, b, c) decides the path complexity according to demand, the complexity parameter designing is initially 1, test case analysis according to five-stage determines whether revising complexity, turns back to this step and regenerates the test case sequence by revising test case library in the 6th one again.
The meaning of a, b, c representative is as follows:
A: many a inner loop
B: increase b circulation
C: the circulation of (nothing) preface is arranged
According to the different values of a, b, c the cycle tests of different complexities is arranged, as shown in table 1.
Table 1 parameter value is to the influence of cycle tests
a b c The description of different complexities
0 0 0 Elementary path
1 0 0 Increase by 1 time inner loop
2 0 0 Increase by 2 times inner loop
2 1 0 Transfer in another loop body by a loop body
2 2 0 Transfer in two other loop body
2 2 1 The unordered transfer of a plurality of loop bodies
Reach the test case sequence that any complexity requires by change to 3 parameters.Specific algorithm just is based on the BFS (Breadth First Search) algorithm of sign tree layout, and algorithm complex can change according to demand.
2.5. five-stage (analytical test use-case)
Analyze the effectiveness of the test case that the quadravalence section obtains, here analytical approach adopts traditional statement covering, judgement covering, condition covering, condition criterion combination covering, the covering of many conditions and the covering of correction decision condition etc., the sign covering of Petri net user-defined counter, transition covering etc.
The component sign of Petri pessimistic concurrency control and transition are pairing to be the main body and the action of incident, and we define two test coverage criterias according to this: sign covers and transition cover.Simultaneously can be in conjunction with traditional test case coverage criterion.
1) sign coverage criterion
It is to cover all model identification with test case that sign covers, and sign is exactly the state of scene, and the complete covering scene of energy then this test case can contain all states.
Sign covering algorithm design: according to sign tree layout before, do not remove merge node, keep the accessible state that contains sign, utilize the sign tree layout can contain all signs, traversal sign tree layout just obtains one group of sequence, this group sequence is exactly the cycle tests of test case, and each group sequence is exactly a test case.The test use cases that obtains according to this standard comprises the sign that all can reach, and what do not contain is exactly unreachable sign, obtains use-case centralised identity number A, and total N then has the sign coverage rate as follows:
&eta; = A N &times; 100 %
2) transition coverage criterion
Transition coverage rate algorithm design: the transition correspondence event in the model of place, and therefore good test case will cover all contingent incidents.Since the generation of transition from not sign, so have and the sign coverage rate is calculated identical method, it is exactly a test case that traversal sign tree layout obtains one group of cycle tests.
Obtain transition number B according to test use cases, sum M then has the transition coverage rate as follows:
&gamma; = B M &times; 100 %
2.6. the 6th stage (analyze and adjust test case library)
Adjust test case library according to the analysis of five-stage, test case is added, deletion, returned the effectiveness of the new test case library of five-stage analysis after revising, reach the purpose that reaches best test effect with minimum test case.
3. advantage and innovation
The present invention has following improvement and innovation to prior art:
(1) the present invention's formalization method of proposing a kind of strictness generates test case automatically.The Petri net that adopts is a kind of complete formal language, employing has the graphic language of formal semantics, than other non-formalization and the test case high conformity that generates of half formalization method, and the generation of system and the method for management software test case more complete than prior art.
(2) the present invention adopts the Componentized method to set up model, so that the analysis of the collection of model structure information and model.The method that has proposed node merging and details shielding is simultaneously come the scale of reduction system.
(3) the present invention has used Petri net theory to model analysis and checking.Petri net theory has perfect analysis theories, as deadlock, activity, boundedness, accessibility etc., by the problem that can avoid model defect to bring to a great extent to the analysis of these model properties, can carry out place mat for better generating superior in quality test case.
(4) the present invention proposes the analytical approach that identifies tree layout.Simplify the scale of reachable marking tree greatly by defining two category nodes, for model analysis provides effective method, the method by the sign tree layout solves the state explosion problem simultaneously.
(5) provided definition and algorithm among the present invention, helped to improve the efficient and the quality of test based on Petri net two class coverage rate indexs.
(6) the invention provides test case and estimate optimization mechanism.Test case not only will generate smoothly, also will satisfy the coverage rate index and the Petri net two class coverage rate indexs of conventional test methodologies.Test use cases is constantly optimized, reached test request.

Claims (3)

1.一种基于PN模型的软件测试用例自动生成方法,其特征在于包括如下步骤:1. a kind of software test case automatic generation method based on PN model, it is characterized in that comprising the steps: 1.)第一阶段根据被测对象建立组件化Petri网模型:1.) In the first stage, a componentized Petri net model is established according to the measured object: (1)如果程序为结构化程序如C语言,由于有固定语法格式:顺序结构、条件结构(if、switch)、循环结构(while、for),则对结构分别建模,Petri网模型就是这些模块的组合;(2)如果程序为00程序如C++,通过半形式化语言UML的状态图、动态图等生成过渡模型,再由UML图转化为Petri网模型;(3)需求描述或者场景直接生成Petri网模型;(1) If the program is a structured program such as C language, due to the fixed grammatical format: sequential structure, conditional structure (if, switch), loop structure (while, for), then the structure is modeled separately, and the Petri net model is these Combination of modules; (2) If the program is a 00 program such as C++, the transition model is generated through the state diagram and dynamic diagram of the semi-formal language UML, and then converted from the UML diagram to the Petri net model; (3) The requirement description or the scene is directly Generate a Petri net model; 2.)第二阶段收集Petri网结构信息:将Petri网模型的各个元素(库所、变迁、有向弧、Token等)用组件化形式表现出来。收集各种元素的信息,即得到Petri网的结构信息:库所、变迁的前集、后集以及初始化条件等;2.) The second stage collects Petri net structure information: each element of the Petri net model (place, transition, directed arc, token, etc.) is represented in a componentized form. Collect the information of various elements to obtain the structural information of the Petri net: places, pre-sets, post-sets of changes, and initialization conditions, etc.; 3.)第三阶段模型分析与验证:利用第二阶段得到的结构信息,结合由Petri网理论生成的相应算法分析Petri网模型的死锁、活性、有界性、可达性等模型特性。发现错误则需要回到第一阶段修改模型;3.) The third stage model analysis and verification: using the structural information obtained in the second stage, combined with the corresponding algorithm generated by the Petri net theory to analyze the model characteristics of the Petri net model such as deadlock, liveness, boundedness, and accessibility. If you find an error, you need to go back to the first stage to modify the model; 4.)第四阶段生成测试用例:用Petri网的可达标识集的分析方法对模型进行分析,用深度优先或广度优先搜索算法对可达树或覆盖图搜索而得到标识序列,对得到测试序列整理生成测试用例集;4.) Generate test cases in the fourth stage: analyze the model with the analysis method of the reachable identification set of Petri net, use the depth-first or breadth-first search algorithm to search the reachable tree or coverage map to obtain the identification sequence, and obtain the test case Sequence sorting to generate test case sets; 5.)第五阶段分析第四阶段得到的测试用例的效用:传统分析方法和自定义方法相结合。传统白盒测试分析方法如语句覆盖、判定覆盖、条件覆盖、条件判定组合覆盖、多条件覆盖和修正判定条件覆盖等;Petri网自定义指标如标识覆盖、变迁覆盖;5.) The fifth stage analyzes the utility of the test cases obtained in the fourth stage: a combination of traditional analysis methods and self-defined methods. Traditional white-box testing analysis methods such as statement coverage, decision coverage, condition coverage, condition decision combination coverage, multi-condition coverage and modified decision condition coverage, etc.; Petri net custom indicators such as identity coverage and transition coverage; 6.)第六阶段根据第五阶段的分析调整测试用例集,对测试用例添加、删除、修改后回到第五阶段重新分析,直至满足用户原始需求与质量要求。6.) The sixth stage adjusts the test case set according to the analysis of the fifth stage, and returns to the fifth stage to re-analyze after adding, deleting, and modifying the test cases until the original needs and quality requirements of the user are met. 2.本发明提出了标识展开树的分析方法。对于Petri网应用中经常出现的状态爆炸问题,用标识展开树的分析方法解决,本方法通过定义循环节点和跳出节点来极大的简化可达标识树的规模,为模型分析提供了有效的方法。2. The present invention proposes an analysis method for identifying the expansion tree. For the problem of state explosion that often occurs in Petri net applications, the analysis method of label expansion tree is used to solve it. This method greatly simplifies the scale of the reachable label tree by defining loop nodes and jumping out nodes, and provides an effective method for model analysis. . 3.本发明提供了测试用例评价优化机制。该机制下测试用例不仅顺利生成,同时通过方法步骤中四、五、六阶段的反复执行对测试用例进行不断的优化,来达到需求。3. The present invention provides a test case evaluation optimization mechanism. Under this mechanism, the test cases are not only generated smoothly, but also the test cases are continuously optimized through the repeated execution of the fourth, fifth and sixth stages of the method steps to meet the requirements.
CN2009100353676A 2009-09-25 2009-09-25 Software test case automatic generating method Pending CN102176200A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2009100353676A CN102176200A (en) 2009-09-25 2009-09-25 Software test case automatic generating method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2009100353676A CN102176200A (en) 2009-09-25 2009-09-25 Software test case automatic generating method

Publications (1)

Publication Number Publication Date
CN102176200A true CN102176200A (en) 2011-09-07

Family

ID=44519385

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2009100353676A Pending CN102176200A (en) 2009-09-25 2009-09-25 Software test case automatic generating method

Country Status (1)

Country Link
CN (1) CN102176200A (en)

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103064788A (en) * 2012-12-24 2013-04-24 清华大学 Web service modeling and test method based on interface semantic contract model
CN103399528A (en) * 2013-03-06 2013-11-20 中国电力科学研究院 Automatic generation method for Modbus slave-station simulator system
CN104243243A (en) * 2014-10-14 2014-12-24 清华大学 Method for generating protocol testing sequence
CN104461887A (en) * 2014-12-11 2015-03-25 吴翔虎 Embedded software black-box test case generation method based on dynamic model
CN104615071A (en) * 2015-01-08 2015-05-13 华侨大学 PLC (programmable logic controller) programming method for automatic stereoscopic warehouse system based on Petri net
CN105591827A (en) * 2014-10-20 2016-05-18 中国科学院沈阳自动化研究所 Method of generating WIA-PA (Wireless networks for Industrial Automation-Process Automation) protocol test set based on equipment life cycle Petri net
CN106294096A (en) * 2015-05-13 2017-01-04 腾讯科技(成都)有限公司 A kind of information processing method and device
CN106528127A (en) * 2016-10-26 2017-03-22 合肥润客软件科技有限公司 Software architecture driver-based distributed system development method
CN106547696A (en) * 2016-10-28 2017-03-29 中国人民解放军理工大学 A kind of method for generating test case and device of Workflow-oriented system
CN108701074A (en) * 2016-02-24 2018-10-23 三菱电机株式会社 Test cases technology device and test case generator
CN109977030A (en) * 2019-04-26 2019-07-05 北京信息科技大学 A kind of test method and equipment of depth random forest program
CN109992498A (en) * 2017-12-29 2019-07-09 北京京东尚科信息技术有限公司 Generation method and system, the computer system of test case
CN110502237A (en) * 2019-09-07 2019-11-26 创新奇智(广州)科技有限公司 A kind of software interface prototype method and tool based on state diagram
CN111639023A (en) * 2020-05-16 2020-09-08 中信银行股份有限公司 Test case generation method and device based on user operation sequence diagram
CN113254325A (en) * 2020-02-10 2021-08-13 北京沃东天骏信息技术有限公司 Test case processing method and device
CN113505082A (en) * 2021-09-09 2021-10-15 腾讯科技(深圳)有限公司 Application program testing method and device
CN115994374A (en) * 2023-03-23 2023-04-21 汶上县金源物流有限公司 Logistics circulation sorting information management method and system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1812347A (en) * 2005-01-24 2006-08-02 华为技术有限公司 Protocol validity verifying and testing method based on mode conversion
US20060265691A1 (en) * 2005-05-20 2006-11-23 Business Machines Corporation System and method for generating test cases

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1812347A (en) * 2005-01-24 2006-08-02 华为技术有限公司 Protocol validity verifying and testing method based on mode conversion
US20060265691A1 (en) * 2005-05-20 2006-11-23 Business Machines Corporation System and method for generating test cases

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
汪琳等: "基于Petri网的动态建模技术的研究", 《计算技术与自动化》 *

Cited By (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103064788B (en) * 2012-12-24 2016-03-23 清华大学 A kind of Web service modeling based on Interface Semantic Contract Model and method of testing
CN103064788A (en) * 2012-12-24 2013-04-24 清华大学 Web service modeling and test method based on interface semantic contract model
CN103399528A (en) * 2013-03-06 2013-11-20 中国电力科学研究院 Automatic generation method for Modbus slave-station simulator system
CN103399528B (en) * 2013-03-06 2016-05-25 中国电力科学研究院 A kind of automatic generation method of Modbus slave station simulation system
CN104243243B (en) * 2014-10-14 2017-08-04 清华大学 A kind of method for generating protocol test sequence
CN104243243A (en) * 2014-10-14 2014-12-24 清华大学 Method for generating protocol testing sequence
CN105591827A (en) * 2014-10-20 2016-05-18 中国科学院沈阳自动化研究所 Method of generating WIA-PA (Wireless networks for Industrial Automation-Process Automation) protocol test set based on equipment life cycle Petri net
CN104461887A (en) * 2014-12-11 2015-03-25 吴翔虎 Embedded software black-box test case generation method based on dynamic model
CN104615071A (en) * 2015-01-08 2015-05-13 华侨大学 PLC (programmable logic controller) programming method for automatic stereoscopic warehouse system based on Petri net
CN106294096A (en) * 2015-05-13 2017-01-04 腾讯科技(成都)有限公司 A kind of information processing method and device
CN106294096B (en) * 2015-05-13 2020-03-17 腾讯科技(成都)有限公司 Information processing method and device
CN108701074A (en) * 2016-02-24 2018-10-23 三菱电机株式会社 Test cases technology device and test case generator
CN106528127A (en) * 2016-10-26 2017-03-22 合肥润客软件科技有限公司 Software architecture driver-based distributed system development method
CN106547696B (en) * 2016-10-28 2019-05-28 中国人民解放军理工大学 A kind of method for generating test case and device of Workflow-oriented system
CN106547696A (en) * 2016-10-28 2017-03-29 中国人民解放军理工大学 A kind of method for generating test case and device of Workflow-oriented system
CN109992498A (en) * 2017-12-29 2019-07-09 北京京东尚科信息技术有限公司 Generation method and system, the computer system of test case
CN109992498B (en) * 2017-12-29 2022-12-02 北京京东尚科信息技术有限公司 Test case generation method, system, and computer system
CN109977030B (en) * 2019-04-26 2022-04-19 北京信息科技大学 Method and device for testing deep random forest program
CN109977030A (en) * 2019-04-26 2019-07-05 北京信息科技大学 A kind of test method and equipment of depth random forest program
CN110502237A (en) * 2019-09-07 2019-11-26 创新奇智(广州)科技有限公司 A kind of software interface prototype method and tool based on state diagram
CN113254325A (en) * 2020-02-10 2021-08-13 北京沃东天骏信息技术有限公司 Test case processing method and device
CN111639023A (en) * 2020-05-16 2020-09-08 中信银行股份有限公司 Test case generation method and device based on user operation sequence diagram
CN113505082B (en) * 2021-09-09 2021-12-14 腾讯科技(深圳)有限公司 Application program testing method and device
CN113505082A (en) * 2021-09-09 2021-10-15 腾讯科技(深圳)有限公司 Application program testing method and device
CN115994374A (en) * 2023-03-23 2023-04-21 汶上县金源物流有限公司 Logistics circulation sorting information management method and system

Similar Documents

Publication Publication Date Title
CN102176200A (en) Software test case automatic generating method
US8930919B2 (en) Modernization of legacy software systems based on modeled dependencies
Han et al. Spark: A big data processing platform based on memory computing
Song et al. Efficient routing on large road networks using hierarchical communities
WO2018171715A1 (en) Automated design method and system applicable for neural network processor
CN103489056A (en) Land evaluation method and expert system integrating ontologe knowledge reasoning and analytical hierarchy process
CN110688754A (en) A Combat Architecture Modeling and Optimal Search Method
Yin et al. DFGNet: Mapping dataflow graph onto CGRA by a deep learning approach
CN103678436A (en) Information processing system and information processing method
CN101901161A (en) A Hierarchical Control Data Flow Graph Modeling Method Oriented to Partitioning Energy-related Software/Hardware
CN109614093A (en) Visualized smart contract system and smart contract processing method
Li et al. Adyna: Accelerating dynamic neural networks with adaptive scheduling
CN111143038B (en) RISC-V architecture microprocessor kernel information model modeling and generating method
Antunes et al. Partitioning and dynamic mapping evaluation for energy consumption minimization on NoC-based MPSoC
Witzke et al. Proactive resource management to optimize distributed workflow executions
CN102082737A (en) Method for replacing Web services based on service priority
Li et al. Siphon extraction for deadlock control in flexible manufacturing systems by using Petri nets
Zhang et al. An optimization algorithm applied to the class integration and test order problem
CN118297027A (en) Chip multi-row detailed layout method and device based on graph structure
CN110109811A (en) A kind of source tracing method towards GPU calculated performance problem
Ma et al. Parallel exact inference on multicore using mapreduce
Jorba et al. Performance Analysis of Parallel Applications with KappaPI 2.
CN119272669B (en) Analysis method of digital logic circuit, computer equipment and storage medium
CN119918590B (en) An intelligent model optimization method based on operator target value regression prediction
Sun et al. Simulators for Deep Neural Network Accelerator Design and Analysis: A Brief Review

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20110907

WD01 Invention patent application deemed withdrawn after publication