CN109542783A - A kind of extended finite state machine test data generating method based on variable segmentation - Google Patents

A kind of extended finite state machine test data generating method based on variable segmentation Download PDF

Info

Publication number
CN109542783A
CN109542783A CN201811373829.0A CN201811373829A CN109542783A CN 109542783 A CN109542783 A CN 109542783A CN 201811373829 A CN201811373829 A CN 201811373829A CN 109542783 A CN109542783 A CN 109542783A
Authority
CN
China
Prior art keywords
variable
matrix
migration
path
test
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201811373829.0A
Other languages
Chinese (zh)
Other versions
CN109542783B (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.)
Beihang University
Original Assignee
Beihang University
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 Beihang University filed Critical Beihang University
Priority to CN201811373829.0A priority Critical patent/CN109542783B/en
Publication of CN109542783A publication Critical patent/CN109542783A/en
Application granted granted Critical
Publication of CN109542783B publication Critical patent/CN109542783B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/12Computing arrangements based on biological models using genetic models
    • G06N3/126Evolutionary algorithms, e.g. genetic algorithms or genetic programming

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Biophysics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Evolutionary Biology (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Artificial Intelligence (AREA)
  • Data Mining & Analysis (AREA)
  • Physiology (AREA)
  • Genetics & Genomics (AREA)
  • Quality & Reliability (AREA)
  • Biomedical Technology (AREA)
  • Computational Linguistics (AREA)
  • Computer Hardware Design (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a kind of extended finite state machine test data generating methods based on variable segmentation, belong to software testing technology field, more particularly to a kind of model-based testing technical field.In the test based on extended finite state machine, the critical issue that test data is obtained using heuristic is how to improve the search efficiency of algorithm.The present invention proposes a kind of automatic method for dividing unrelated input variable in test path on the basis of genetic algorithm.This method is characterized in by analysing in depth the relationship in model between variable and variable, variable and predicate conditions, judgement does not influence the unrelated input variable of predicate conditions and its starting segmentation migration in subpath, a dynamic eXecute UML frame is developed simultaneously to feed back to information needed for providing algorithm, divisible input variable is then gradually separated from individual in the search process of genetic algorithm the automatic reduction to realize search space, the test data for quickly generating target detection path, improves Test data generation efficiency.

Description

A kind of extended finite state machine test data generating method based on variable segmentation
Technical field
The invention belongs to software testing technology field, more particularly to a kind of model-based testing technical field, to Determine, the unrelated input variable in segmentation extended finite state machine Test data generation, specifically referring to a kind of based on variable point The extended finite state machine test data generating method cut.
Background technique
Software test is for guaranteeing that software quality has key effect.Model is a kind of abstractdesription of software systems, base Where the test (Model-Based Testing, MBT) of model is to determine software error using the method for formalization, thus Ensure the correctness and reliability of software under testing.Since MBT is not for a certain program code itself, thus it is widely used in software The product test of life cycle early stage is particularly suitable for assessment early period that long-drawn-out relationship is united safely such as aerospace software, is Important one of the research direction in software test field.In MBT, extended finite state machine (Extended Finite State Machine, EFSM) with finite state machine (Finite State Machine, FSM) be two kinds of test models the most general, Wherein EFSM is used by the bottom behavior model as modeling languages such as SDL, UML, Simulink always, it is the base in FSM Variable, operation and the predicate conditions of state transition are introduced on plinth, thus are more suitable for description compared to FSM and are such as embedded in The complicated applications system such as formula and communication protocol software.Following both sides is primarily present currently based on the test of EFSM model to choose War: first is that executable test path how is generated, second is that the generation of the corresponding test data of test path.
There are many test data generating methods for being directed to extended finite state machine, including relaxing techniques, section to calculate at present Art, Function Minimization Method etc., since often there are complicated connections between variable in EFSM, thus these types obtains test number According to method success rate it is not high, also need manually to participate in some cases, undoubtedly reduce the testing efficiency of software.With these types Method is different, and using heuritic approach to generate test data is that cost function is dynamically searched for input variable as feedback quantity Value, the test input value for meeting predicate in target detection path and constraining is obtained with this, thus whole process can use Automatic method is realized.Furthermore there is also there are many mechanism for jumping out local extremum, such as simulated annealing in heuritic approach In Metropolis criterion, the operation such as selection, intersection, variation in genetic algorithm, these mechanism have algorithm entirely The ability of office's optimizing, practical application show that heuritic approach can greatly improve Test data generation compared with other several methods Efficiency and success rate.
Although heuritic approach has many advantages, such as but there is also following deficiencies:
1) when solving the problems, such as combinatorial optimization problem the complexity of algorithm and scale it is proportional, the life for test data For, when input variable number is more, search the time it takes expense can be dramatically increased, or even the hardly possible in finite time To generate validity test data.
2) when meeting the input variable value of constraint condition using heuristic solution, all input variables can be changed simultaneously Value and keep cost function close to being correctly oriented because every time only consider a constraint condition, find out satisfaction should It needs to search for the variate-value for meeting next constraint condition on the basis of current variable values after the variate-value of constraint condition, if certain The value that a little variables are unsatisfactory for next condition again and can change all variables re-searches for, and this search process will lead to other This becomes no longer to meet to meet the variable of whole constraint conditions, increases the probability repeatedly recalled.
Automated test data generation technology based on variable segmentation aims to solve the problem that the above problem.The automatic metaplasia of the test data At method by the irrelevant variable in discriminating test path, and it is heuristic to reduce as far as possible to divide unrelated input variable therein The search space of algorithm reduces the scale of problem with this;The value of unrelated input variable divided at the same time is replaced by often For number to be fixed up, subsequent searches process will no longer change the value of these variables, and the probability of backtracking search will be effectively reduced in this, with Reduce the time overhead of Test data generation.
Summary of the invention
The problem to be solved in the present invention is: by the judgement and segmentation to irrelevant variable in target detection path, to contract Subtract the search space of heuritic approach search test data, the test input data of the generation software under testing of automation substantially mentions The formation efficiency of high test data.
A kind of extended finite state machine test data generating method based on variable segmentation provided by the invention, including it is following Step:
Step 1) establishes the extended finite state machine model of software under testing, generates from initial state node to other nodes Test path Candidate Set then pre-processes the test path in the test path Candidate Set, and removes test path Not executable test path in Candidate Set;
Step 2) chooses a target detection path from pretreated test path Candidate Set, analyzes target detection road Dependence in diameter between variable and migration determines that the unrelated input variable in target detection path and its starting segmentation are moved It moves;
Step 3) establishes eXecute UML, makes extended finite state machine model executableization using semantic analytic method, EXecute UML makes extended finite state machine EFSM be provided with the ability of the dynamic operation as software program, so as to for Heuritic approach is fed back when providing operation;
Step 4) uses the test data in Genetic algorithm searching target detection path, if what current test data can pass through Test path includes that migration is divided in the starting of divisible input variable, then the value for directly fixing these divisible input variables is Constant, only needs the value for searching for remaining input variable to be until being successfully generated test data in later genetic algorithm iteration Only.
Mainly comprising the processes of for the generation of test data generates the EFSM model of software by step 1) first and meets migration The test path Candidate Set of covering then chooses a test path in the test path Candidate Set as target detection road Diameter, and the unrelated input variable in the target detection path is obtained according to step 2) and its originates segmentation migration, it is opened by step 3) The eXecute UML of hair and step 4) obtain feedback information when operation, as the fitness value of genetic algorithm, and will Unrelated input variable is divided away, and with the reduction of input variable number, the search space of genetic algorithm is gradually reduced, will be very big Raising search efficiency.
The EFSM model is made of one hexa-atomic group (S, S0, I, O, T, V), and wherein S is the state set of the EFSM, S0 For original state, I is input massage set, and O is the output massage set of non-empty, and T is state transition set, and V is the collection of variable It closes.
Pretreatment described in step 1) refers specifically to: since input variable same in EFSM model symbol may be in different shapes Occur in the input variable table of state migration, in order to indicate that the value that they are represented is different, needs the input in each state transition Variable is rewritten as vtiForm with show distinguish, wherein v be input variable identifier, tiIt is the identifier of some state transition.
Variable described in step 2) and migration between dependence include two aspect, first is that the value of variable whether by To the influence (the referred to as relationship of variable and variable) for migrating its dependent variable in upper assignment statement and predicate conditions, second is that predicate item Whether the satisfaction of part will receive the influence of certain variables.
Feedback information when being run described in step 3) are as follows:
Wherein F is value of feedback, and the total test path length of approach_level can be triggered with current test data The difference of test path length, branch_distance are that current test data and satisfaction do not trigger when migrating upper predicate conditions Degree of closeness.
The present invention has the advantages that
1) this method reduces the search of heuritic approach by the unrelated input variable in judgement and segmentation test path Space, to improve Test data generation efficiency;
2) the deep dependence analyzed in test path between variable and between variable and predicate conditions, and give bright True definition statement;
3) the automatic realization algorithm that unrelated input variable determines with divides is given;
4) feedback when realizing dynamic eXecute UML to provide operation by semantic analysis technology, and calculated using heredity Method realizes final Test data generation.
By this 4 points combine, be shown experimentally that: unrelated input variable it is automatic judgement with partitioning algorithm be effectively, this Kind method can successfully reduce the search space of genetic algorithm.In addition, in the case where the total space is searched for traditional genetic algorithm and with Machine algorithm is compared, method proposed by the present invention to target path set generate validity test data have higher success rate, and it is required into Change algebra and runing time is less, stability is more preferable.
Detailed description of the invention
Fig. 1 is whole implementation flow chart of the invention;
Fig. 2 Genetic algorithm searching spatial variations schematic diagram;
Fig. 3 is a target detection path in EFSM;
Fig. 4 is the relational graph in the path Fig. 3 between each variable;
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention clearer, below in conjunction with specific implementation case, and join According to attached drawing, the present invention is described in more detail.Following case study on implementation is only used for clearly illustrating technical side of the invention Case, and not intended to limit the protection scope of the present invention.
General Implementing flow chart of the invention as shown in Figure 1, the test data generating method the following steps are included:
Step 1) converts EFSM model for tested software program in a computer, is generated and is surveyed using the method for figure traversal Try path candidates collection.
Step 2) pre-processes test path Candidate Set for the test path Candidate Set in step 1), will be different The variable for migrating same names in input variable table is indicated using different symbols, is then removed in test path Candidate Set not Executable test path, and a test path in test path Candidate Set is randomly selected as target detection path;
Step 3) finds out the nothing in target detection path using the decision algorithm of irrelevant variable for target detection path Close input variable and its starting segmentation migration;
Step 4) realizes the executable frame of an EFSM dynamic, thus feedback when providing operation for heuritic approach;
Step 5) realizes the test data in target detection path using genetic algorithm, uses irrelevant variable in this course Partitioning algorithm divides the unrelated input variable in test path automatically, gradually reduces the search space of algorithm;
The input variable value that step 6) finally obtains step 5) is as the test input data of EFSM destination path to be measured.
In the following, by explanation is described in detail to related step:
(1) EFSM model and problem model
[defining 1] extended finite state machine M is made of one hexa-atomic group (S, S0, I, O, T, V), and wherein S is non-null states Set, S0 are original state, and I is input massage set, and O is output massage set, and T is state transition set, and V is variables set It closes.Element in state transition set T is migration t by five-tuple (Si,i,g,op,ST) composition, wherein SiIt is to migrate setting out for t State, i ∈ I are input message, and g is the predicate conditions for migrating t and executing, and op is then the assignment statement or output statement group by variable It closes, STIt is the arrival state of state transition t.
Variables collection V in EFSM is by triple (Iv,Cv,Ov) constitute, wherein IvIndicate input variable set, OvIndicate defeated Variables collection out, CvIndicate environmental variance set, the value of input variable can be taking human as being controlled, and output variable and environment Then tested person personnel control, their value are not determined variable by the corresponding operating in migration.
Test path (Test Path, TP) in EFSM is defined as a migration series, i.e. TP=[t1,t2,…,tn], Wherein { t1,The corresponding predicate conditions sequence GP=[g of TP1,g2,…,gn], if tkFor the shape in test path TP State migration, gkTo migrate tkPredicate conditions be then expressed as tk→ TP, gk→GP.Wherein, k=1,2 ..., n, n are test The number migrated in path.
Initial testing set of paths is obtained using figure traversal method, since input variable same in test path symbol is possible to Occur in the input variable table of different state transition, in order to indicate that the value that they are represented is different, each state is needed to move Input variable in shifting is rewritten asForm with show distinguish.For example, if some input variable x is in two state transition t1And t2 Input variable list in occur simultaneously, in order to distinguish the different input values of the variable, need in initial phase the variable It is rewritten as respectively
The test data of each test path is searched for using random algorithm for the infeasible path in discriminating test set of paths, If finding test data not successfully in given number of iterations, then it is assumed that the test path is infeasible, it is removed from set, Final remaining test path then can be used as target detection path.
The generation problem of test data can be described as in EFSM:
1) the EFSM model M for choosing a software under testing chooses a test path TP in EFSM model M as target Test path;
2) valued space of input variable in the EFSM model M of software under testing is set as D, seeks test data x ∈ D, so that Using test data x as input, in Dynamic Execution EFSM model M, the test path that can pass through is TP.
The test data for obtaining EFSM model M automatically using genetic algorithm, needs to be modeled as a kind of optimization problem.
Different test datas is updated to the test path being actually passed through in TP and the close journey in target detection path Fitness of the feedback as each test data, is denoted as F when degree is runi(x), i=1,2 ..., n, n are of test data Number.The calculation of value of feedback are as follows:
Wherein approach_level is that the test path that total test path length and current test data can trigger is long The difference of degree, branch_distance is current test data and meets the degree of closeness not triggered when migrating upper predicate conditions.
According to fitness function, one minimum of function can be established for Test data generation problem in EFSM model M Change model:
(2) judgement of irrelevant variable and dividing method;
The variable for not influencing test path subpath predicate conditions is known as irrelevant variable in EFSM model M.And EFSM mould In type M with variable there are the migration element of dependence include migration in assignment statement or output statement op and migration execute Predicate conditions g, wherein output statement only carry out variable output operation, can't variation value, therefore variable with The relationship of state transition includes relationship (the referred to as variable and variable of its dependent variable in variable and assignment statement and predicate conditions Relationship) and predicate conditions and variable relationship two parts.
1. the relationship of variable and variable:
If the variables collection V={ x of the EFSM model M of software under testing0,x1,…,xn-1, state transition set T={ t0, t1,…,te-1, target detection path TP=[t0,t1,…,tm-1], the corresponding predicate conditions sequence GP=[g of TP1,g2,…, gm-1], wherein n is the number of variable in set V, and m is the number that TP includes migration, and e is migrated in state transition set T Number;Have defined below:
[defining 2] sets migration td∈ T, ifxj∈ V, so that tdAssignment statement in variable xiValue depend on Variable xj, it is expressed as xi=f (xj)d, then in migration tdMiddle xiDepend directly on xj;Ifxj∈ V, so that tdPredicate item It both include x in partiIt again include xj, then in tdMiddle xiWith xjIt mutually directly relies on, i.e. xi=f (xj)d, xj=f (xi)d
[defining 3] is in the TP of target detection path, if migration td→ TP, ifxj∈ V, xk∈ V, so that tdMiddle change Measure xiDepend directly on xk, but and it is not directly dependent on xj, i.e. xi=f (xk)d, but in tdT is migrated beforebX in (b < d)kDirectly according to Rely in xj, i.e. xk=f (xj)b, then claim in tdMiddle variable xiIndirectly depend on variable xj
It is defined in 2 for convenience of description and directly relies on relationship, can established between variable for each migration of EFSM model M Matrix is directly relied on, and it is different to indirectly rely on relationship its dependence matrix when for different target detection paths, and closes System is complicated, behind will be between the connectivity judgment variable that be given by figure with the presence or absence of the method for indirectly relying on relationship.
[defining 4] is for EFSM model M, if migrating td∈ T, then tdDirectly relying on matrix and square can be tieed up by n between middle variable Battle array Pd=(pij)n×nIt indicates, wherein n is the number of variable in set V, matrix PdIn element pijIt is defined as follows:
Direct and indirect two kinds can also be divided into for the dependence of predicate conditions and variable.
[defining 5] sets migration td∈ T, ifSo that tdPredicate conditions gdInclude variable xi, then it is assumed that gdTo xiIt deposits Directly relying on relationship.
[defining 6] is in the TP of target detection path, if migration td→ TP, if for migrating tdPredicate conditions gd(gd→ GP),xj∈ V makes gdDepend directly on variable xj, and it is not directly dependent on variable xi, but in tdT is migrated beforeb(b< D) variable x injDependent on xi, i.e. xj=f (xi)b, then it is assumed that predicate conditions gdTo variable xiIn the presence of indirectly relying on relationship.
The direct or indirect dependence of predicate conditions and variable in the TP of target detection path is referred to as in the present invention There is dependence for the two, this relationship can also establish the corresponding matrix that relies on and be described.
[defining 7] is in the TP of target detection path, if migration td→ TP, tdPredicate conditions gdWith variable xiThe dependence of ∈ V Relationship can tie up matrix Q=(q by n × mij)n×mIt indicates, wherein n is the number of variable in set V, and m is that TP includes migration It counts, the element q in matrix QijIt is defined as follows:
By defining 5, defining 6, defining 7 it is found that dependence matrix description between predicate conditions and variable variable is in the survey The life cycle in path is tried, therefore there are following properties:
[property 1] sets input variable collection in the EFSM model M of software under testing and is combined into IvIfSo that matrix Q In the i-th row element be 0, then for test path TP, xi∈ V is irrelevant variable;IfForm- 1] element q in matrix Qij=0, and to j=u-1 element qij≠ 0, wherein [1, m-1] u ∈, then in subpath TP '=[t of TPu, tu+1,…,tm-1] in xi∈ V is irrelevant variable, if x simultaneouslyi∈IvInput variable x can be then fixed in TP or TP 'iValue And from IvIt is middle to be divided, and by tu-1It is defined as variable xiStarting divide migration.
2. the automatic decision algorithm of irrelevant variable;
For whether there is irrelevant variable in a test path, depending on the dependence matrix Q between predicate conditions and variable, Relationship is directly relied on for predicate conditions and variable, can by whether being obtained comprising the variable in scanning predicate conditions, and The relationship of indirectly relying on needs the relationship for relying on variable and variable to be judged, the calculating side for relying on matrix P and matrix Q is given below Method.
Matrix P calculation method is directly relied between [algorithm 1] variable
Input the variables collection V={ x of .EFSM model M0,x1,…,xn-1, migrate set T={ t0,t1,…,te-1}
Output directly relies on matrix P0,P1,…,Pe-1
Step1. a certain migration t for not setting up and relying on matrix is selectedd∈ T establishes n dimension matrix PdAnd initializing element is 0.
Step2. scanning migration tdIn each assignment statement, ifxj∈ V makes xi=it { include xjExpression Formula }, then enable pij=1.
Step3. scanning migration tdPredicate conditions, ifxj∈ V makes in condition i.e. comprising xiIt again include xj, then Enable pij=pji=1.
Step4. output matrix Pd, judge whether to have in EFSM model M and do not set up the migration for directly relying on matrix, turn if having To Step1.
Step5. algorithm terminates.
It can be obtained in all state transitions of EFSM model M to be measured the matrix that directly relies between variable by algorithm 1, and square Relational graph G before each migration that the calculating of battle array Q needs first to establish test path in all migrations between variable, the pass between variable Be figure it is essentially a kind of digraph, thus can be indicated using the adjacency matrix in graph theory, method for building up is as follows:
The method for building up of [algorithm 2] relational graph G
Input .EFSM model M variables collection V={ x0,x1,…,xn-1, matrix P is directly relied between variable0,P1,…, Pe-1, target detection path TP=[t0,t1,…,tm-1]
Export the adjacency matrix sequence R=[R of relational graph0,R1,…,Rm-1]
Step1. a certain migration t for not setting up relational graph is selectedd→ TP, with variable x0,x1,…,xn-1N as digraph A vertex, establishes tdRelational graph Gd
Step2. t in TP is scanneddAnd its between the corresponding variable of all migrations matrix is directly relied on before, if variable in matrix xj∈ V is to variable xi∈ V, which exists, directly relies on relationship, then from vertex xiX apicadjEstablish a directed edge.
Step3. by GdIt is converted into adjacency matrix RdAnd export, judge the migration for whether not setting up relational graph in TP also, if Go to Step1.
Step4. algorithm terminates;
After opening relationships figure, according to the available following property of the digraph:
The relational graph G that [property 2] utilizes algorithm 2 to generatedIn, if variable xiTo xjThere are an access, then xiWith xjIt is moving Move tdOr tdThere are dependence in migration before, and variable xjDependent on xi
According to property 2, it can find out and rely on matrix Q.
The calculation method of [algorithm 3] matrix Q;
Input .EFSM model M variables collection V={ x0,x1,…,xn-1, target detection path TP=[t0,t1,…, tm-1], the corresponding predicate conditions sequence GP=[g of TP0,g1,…,gm-1], adjacency matrix sequence R=[R0,R1,…,Rm-1]
It exports and relies on matrix Q
Step1. a certain predicate conditions g not scanned in GP is selectedj, scan gjIt whether include variable xi∈ V, if comprising if Enable qij=1.
If Step2. qij=1, then adjacency matrix R is judged using depth-priority-searching methodj-1Middle variable vk(xk∈ V, k ≠ i) be It is no to have to viAccess, access, then enable q if it existskj=1.
Step3. judge whether there is also the predicate conditions not scanned in GP, if going to Step1.
Step4. output matrix Q, algorithm terminate.
After obtaining matrix Q, unrelated input variable x can be obtained according to property 1iAnd its corresponding starting segmentation is moved It moves.
3. the automatic division method of unrelated input variable;
If the input variable that the EFSM model M of software under testing includes is Iv={ x1,x2,…,xn, the valued space of variable For D, a target detection path TP=[t in EFSM model M is chosen0,t1,…,tm-1], if initial kind that genetic algorithm generates Group includes k individual, and the corresponding test data of Different Individual is respectively v1,v2,…,vk, vk∈ D, Different Individual are corresponded to it and are surveyed Data are tried as input, in Dynamic Execution EFSM model M, the path that can be actually passed through is respectively TP1,TP2,…,TPk, with | TP | expression can be by the length in path.The dividing method of unrelated input variable are as follows: in each iteration, investigate in population By the longest individual i of path length, corresponding test data is vi, investigate the path TP of its processiIn whether comprising divisible Input variable xjCorresponding starting segmentation migration, if comprising if variable x can be removed in all individualsj, in iteration later xjValue with constant c replacement, c be individual i in xjValue.
The present invention achievees the purpose that reduce search space by the unrelated input variable in segmentation test path, to mention Test data generation efficiency is risen, if the input variable I in the EFSM model M of software under testingv={ x1,x2,…,xn, different variables Input domain be respectively D1,D2,…,Dn, then the search space of genetic algorithm are as follows:
When genetic algorithm is in iteration t respectively1,t2,…,tmWhen secondary, optimum individual can divide certain input variables in population, if In different the number of iterations, alienable variable is respectively AndThen search space will become respectively at this time:
If the space of the test path target solution is Dr, then D,And DrRelationship can be indicated with Fig. 2. As shown in Figure 2, increasing with segmentation variable, search space is gradually reduced, and is scanned in smaller search space, will be shown Write the search efficiency for improving genetic algorithm.
Example: Fig. 3 is a test path in EFSM model M, test path TP=[t1,t2,t3,t4], corresponding meaning Entry part is respectively g1={ a<5&&b>2 }, g2={ a > 2 }, g3={ c==3 }, g4={ d >=1 }, assignment statement op1={ b=a +d}、op2={ a=b+a, c=b+d }, op3={ b=c-a }, op4={ d=c+a }, variables collection V=Iv={ a, b, c, d }, It is first depending on algorithm 1 and calculates t1~t4Matrix is directly relied between variable in migration:
{ t is made respectively according to algorithm 2 and dependence matrix P1}、{t1,t2}、{t1,t2,t3}、{t1,t2,t3,t4In variable Relational graph G between variable1、G2、G3、G4, as shown in figure 4, figure (a) (b) (c) (d) respectively indicates corresponding relational graph G1、G2、 G3、G4
It can establish corresponding adjacency matrix sequence R=[R according to relational graph1,R2,R3,R4], it obtains after R according to algorithm 3 It can calculate and rely on matrix Q:
According to matrix Q and algorithm 4 it follows that the value of variable { a, b, c, d } can be to migration t3Predicate conditions can Satisfaction impacts, and migrates t4Predicate conditions only influenced by variable d, since { a, b, c, d } is input variable, therefore For subpath TP '=t of TP4For, variable { a, b, c } belongs to unrelated input variable, can divide, starting segmentation migration For t3, and the corresponding starting segmentation migration of variable d is t4, illustrate that it cannot divide in entire test path.
If genetic algorithm, when evolving to certain generation, the preferably individual paths traversed of fitness value is [t in population1,t2, t3], correspond to test data v={ a=3, b=7, c=4, d=0 }, due to the individual paths traversed comprising variable a, b, The starting segmentation migration t of c3, therefore can fix these three variables is constant, constant value is { a=3, b=7, c=4 }, and from They are removed in all individuals, genetic algorithm only needs the value of search variables d in later iteration.
Below by experimental verification method provided by the invention.(Global Space will be searched for using the total space Search, GSS) traditional genetic algorithm divide (Irrelevant Input with unrelated input variable in the present invention Variables Separation, IIVS) genetic algorithm compare, while use random algorithm (Random Algorithm, RA) comparison as genetic algorithm, three kinds of methods are applied to the survey of tri- group model of ATM, INRES and Casher It tries data to generate, the relevant information of this three group model is as shown in table 1.
Table 1: experimental model and irrelevant variable determine the time
15 experiments are carried out respectively in different input variable value intervals to all experiment paths using three kinds of algorithms, Statistics corresponding averagely evolutionary generation and runing time, as shown in table 2.
Table 2: the average evolutionary generation and runing time of algorithms of different:
Method is compared with the traditional method in the present invention from the data in the table, generates validity test data to target path set Have higher success rate, required evolutionary generation and runing time are less, more efficient, have reached expected purpose.
What the present invention was not disclosed in detail partly belongs to techniques known.
Although the illustrative specific embodiment of the present invention is described above, in order to the technology of the art Personnel understand the present invention, it should be apparent that the present invention is not limited to the range of specific embodiment, to the common skill of the art For art personnel, if various change the attached claims limit and determine the spirit and scope of the present invention in, these Variation is it will be apparent that all utilize the innovation and creation of present inventive concept in the column of protection.

Claims (6)

1. it is a kind of based on variable segmentation extended finite state machine test data generating method, it is characterised in that: specifically include with Lower step,
Step 1) establishes the extended finite state machine model of software under testing, generates the test from initial state node to other nodes Path candidates collection then pre-processes the test path in the test path Candidate Set, and removes test path candidate Concentrate not executable test path;
Step 2) chooses a target detection path from pretreated test path Candidate Set, analyzes in target detection path Dependence between variable and migration determines unrelated input variable and its starting segmentation migration in target detection path;
Step 3) establishes eXecute UML, makes extended finite state machine model executableization using semantic analytic method, to open Hairdo algorithm is fed back when providing operation;
Step 4) uses the test data in Genetic algorithm searching target detection path, if the test that current test data can pass through Path includes that migration is divided in the starting of divisible input variable, then it is normal for directly fixing the value of these divisible input variables Number, only needs the value for searching for remaining input variable until being successfully generated test data in later genetic algorithm iteration.
2. a kind of extended finite state machine test data generating method based on variable segmentation according to claim 1, Be characterized in that: extended finite state machine M is made of one hexa-atomic group (S, S0, I, O, T, V), and wherein S is non-null states set, S0 For original state, I is input massage set, and O is output massage set, and T is state transition set, and V is variables collection;State is moved The element moved in set T is migration t by five-tuple (Si,i,g,op,ST) composition, wherein SiIt is the state of setting out for migrating t, i ∈ I It is input message, g is the predicate conditions for migrating t and executing, and op is composed of the assignment statement or output statement of variable, ST It is the arrival state of state transition t;
Variables collection V in extended finite state machine M is by triple (Iv,Cv,Ov) constitute, wherein IvIndicate input variable set, OvIndicate output variable set, CvIndicate environmental variance set;
Test path in extended finite state machine M is defined as a migration series, i.e. TP=[t1,t2,…,tn], wherein The corresponding predicate conditions sequence GP=[g of TP1,g2,…,gn], if tkIt is moved for the state in test path TP It moves, gkTo migrate tkPredicate conditions be then expressed as tk→ TP, gk→GP;Wherein, k=1,2 ..., n, n are test path The number of middle migration;Initial testing set of paths is obtained using figure traversal method.
3. a kind of extended finite state machine Test data generation side based on variable segmentation according to claim 1 Method, it is characterised in that: the dependence between variable described in step 2) and migration includes two aspects, first is that the value of variable Whether influenced by migrating its dependent variable in upper assignment statement and predicate conditions, referred to as the relationship of variable and variable, second is that Whether the satisfaction of predicate conditions will receive the influence of certain variables.
4. a kind of extended finite state machine Test data generation side based on variable segmentation according to claim 1 Method, it is characterised in that: the unrelated input variable in judgement target detection path described in step 2), automatic decision algorithm are as follows:
For whether there is irrelevant variable in a test path, depending on the dependence matrix Q between predicate conditions and variable, for Whether predicate conditions and variable directly rely on relationship, by obtaining comprising the variable in scanning predicate conditions, and indirectly rely on Relationship needs the relationship for relying on variable and variable to be judged, the calculation method for relying on matrix P and matrix Q is given below;
Matrix P calculation method is directly relied between [algorithm 1] variable
Input the variables collection V={ x of .EFSM model M0,x1,…,xn-1, migrate set T={ t0,t1,…,te-1}
Output directly relies on matrix P0,P1,…,Pe-1
Step1. a certain migration t for not setting up and relying on matrix is selectedd∈ T establishes n dimension matrix PdAnd initializing element is 0;
Step2. scanning migration tdIn each assignment statement, ifxj∈ V makes xi=it { include xjExpression formula, then Enable pij=1;
Step3. scanning migration tdPredicate conditions, ifxj∈ V makes in condition i.e. comprising xiIt again include xj, then p is enabledij =pji=1;
Step4. output matrix Pd, judge whether to have in EFSM model M and do not set up the migration for directly relying on matrix, if going to Step1;
Step5. algorithm terminates;
The matrix that directly relies between variable is obtained in all state transitions of EFSM model M to be measured by algorithm 1, and the meter of matrix Q The relational graph G before each migration for needing first to establish test path in all migrations between variable is calculated, the relational graph between variable is real It is a kind of digraph in matter, thus is indicated using the adjacency matrix in graph theory, method for building up is as follows:
The method for building up of [algorithm 2] relational graph G
Input .EFSM model M variables collection V={ x0,x1,…,xn-1, matrix P is directly relied between variable0,P1,…,Pe-1, target Test path TP=[t0,t1,…,tm-1]
Export the adjacency matrix sequence R=[R of relational graph0,R1,…,Rm-1]
Step1. a certain migration t for not setting up relational graph is selectedd→ TP, with variable x0,x1,…,xn-1The n top as digraph Point, establishes tdRelational graph Gd
Step2. t in TP is scanneddAnd its between the corresponding variable of all migrations matrix is directly relied on before, if variable x in matrixj∈V To variable xi∈ V, which exists, directly relies on relationship, then from vertex xiX apicadjEstablish a directed edge;
Step3. by GdIt is converted into adjacency matrix RdAnd export, judge whether do not set up the migration of relational graph also in TP, turns if having To Step1;
Step4. algorithm terminates;
After opening relationships figure, following property is obtained according to the digraph:
The relational graph G that [property 2] utilizes algorithm 2 to generatedIn, if variable xiTo xjThere are an access, then xiWith xjIn migration td Or tdThere are dependence in migration before, and variable xjDependent on xi
According to property 2, that is, finds out and rely on matrix Q;
The calculation method of [algorithm 3] dependence matrix Q;
Input .EFSM model M variables collection V={ x0,x1,…,xn-1, target detection path TP=[t0,t1,…,tm-1], TP pairs The predicate conditions sequence GP=[g answered0,g1,…,gm-1], adjacency matrix sequence R=[R0,R1,…,Rm-1]
It exports and relies on matrix Q
Step1. a certain predicate conditions g not scanned in GP is selectedj, scan gjIt whether include variable xi∈ V, if enabling q comprising ifij =1;
If Step2. qij=1, then adjacency matrix R is judged using depth-priority-searching methodj-1Middle variable vk(xk∈ V, k ≠ i) whether have To viAccess, access, then enable q if it existskj=1;
Step3. judge whether there is also the predicate conditions not scanned in GP, if going to Step1;
Step4. output matrix Q, algorithm terminate;
After obtaining relying on matrix Q, unrelated input variable x is obtained according to property 1iAnd its corresponding starting segmentation migration.
5. a kind of extended finite state machine Test data generation side based on variable segmentation according to claim 1 Method, it is characterised in that: during the test data for using Genetic algorithm searching target detection path in step 4), pass through segmentation and survey Examination path in unrelated input variable with achieve the purpose that reduce search space, specifically: set in the EFSM model M of software under testing Input variable Iv={ x1,x2,…,xn, the input domain of different variables is respectively D1,D2,…,Dn, then the search of genetic algorithm Space are as follows:
When genetic algorithm is in iteration t respectively1,t2,…,tmWhen secondary, optimum individual divides certain input variables in population, if changing in difference Alienable variable is respectively when generation number AndThen search space will become respectively at this time:
If the space of the test path target solution is Dr, then with increasing for variable is divided, search space is gradually reduced.
6. a kind of extended finite state machine Test data generation side based on variable segmentation according to claim 1 Method, it is characterised in that: fed back when being run described in step 3), feedback information are as follows:
Wherein F is value of feedback, and approach_level is the test that total test path length and current test data can trigger The difference of path length, branch_distance do not trigger approaching when migrating upper predicate conditions for current test data and satisfaction Degree.
CN201811373829.0A 2018-11-19 2018-11-19 Extended finite-state machine test data generation method based on variable segmentation Active CN109542783B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811373829.0A CN109542783B (en) 2018-11-19 2018-11-19 Extended finite-state machine test data generation method based on variable segmentation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811373829.0A CN109542783B (en) 2018-11-19 2018-11-19 Extended finite-state machine test data generation method based on variable segmentation

Publications (2)

Publication Number Publication Date
CN109542783A true CN109542783A (en) 2019-03-29
CN109542783B CN109542783B (en) 2021-07-09

Family

ID=65847965

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811373829.0A Active CN109542783B (en) 2018-11-19 2018-11-19 Extended finite-state machine test data generation method based on variable segmentation

Country Status (1)

Country Link
CN (1) CN109542783B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111367822A (en) * 2020-05-26 2020-07-03 南京大学 Regression testing method and device based on finite state machine
CN111930631A (en) * 2020-08-17 2020-11-13 南宁师范大学 Probability finite state machine mutation test case generation method
CN112306889A (en) * 2020-11-23 2021-02-02 国网北京市电力公司 Charging pile testing method and device, storage medium and processor
CN112699052A (en) * 2020-08-03 2021-04-23 徐州工程学院 Software test case evolution generation method based on relevant input variables
CN114253524A (en) * 2021-12-20 2022-03-29 山东浪潮科学研究院有限公司 Method for assisting logic code design of state machine based on script

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1039391A2 (en) * 1999-03-04 2000-09-27 The Secretary of State for Trade and Industry of Her Majesty's Britannic Government Method and apparatus for testing of a finite state machine
CN102368226A (en) * 2011-10-10 2012-03-07 南京大学 Method for automatically generating test cases based on analysis on feasible paths of EFSM (extended finite state machine)
CN104077228A (en) * 2014-07-08 2014-10-01 浙江理工大学 EFSM performable test sequence generating method based on predicate dependency graph

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1039391A2 (en) * 1999-03-04 2000-09-27 The Secretary of State for Trade and Industry of Her Majesty's Britannic Government Method and apparatus for testing of a finite state machine
CN102368226A (en) * 2011-10-10 2012-03-07 南京大学 Method for automatically generating test cases based on analysis on feasible paths of EFSM (extended finite state machine)
CN104077228A (en) * 2014-07-08 2014-10-01 浙江理工大学 EFSM performable test sequence generating method based on predicate dependency graph

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
HYORIN CHOI: "Applying Meta-Heuristic Algorithm based on Slicing Input Variables to Support Automated Test Data Generation", 《KIPS TR. SOFTWARE AND DATA ENG.》 *
苏宁等: "基于EFSM不定型切片测试用例自动生成的研究", 《计算机研究与发展》 *

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111367822A (en) * 2020-05-26 2020-07-03 南京大学 Regression testing method and device based on finite state machine
CN112699052A (en) * 2020-08-03 2021-04-23 徐州工程学院 Software test case evolution generation method based on relevant input variables
CN112699052B (en) * 2020-08-03 2022-04-15 徐州工程学院 Software test case evolution generation method based on relevant input variables
CN111930631A (en) * 2020-08-17 2020-11-13 南宁师范大学 Probability finite state machine mutation test case generation method
CN111930631B (en) * 2020-08-17 2022-09-09 南宁师范大学 Probability finite state machine mutation test case generation method
CN112306889A (en) * 2020-11-23 2021-02-02 国网北京市电力公司 Charging pile testing method and device, storage medium and processor
CN112306889B (en) * 2020-11-23 2023-10-20 国网北京市电力公司 Method and device for testing charging pile, storage medium and processor
CN114253524A (en) * 2021-12-20 2022-03-29 山东浪潮科学研究院有限公司 Method for assisting logic code design of state machine based on script
CN114253524B (en) * 2021-12-20 2024-05-24 山东浪潮科学研究院有限公司 Script-based method for assisting logic code design of state machine

Also Published As

Publication number Publication date
CN109542783B (en) 2021-07-09

Similar Documents

Publication Publication Date Title
CN109542783A (en) A kind of extended finite state machine test data generating method based on variable segmentation
Carletti et al. Challenging the time complexity of exact subgraph isomorphism for huge and dense graphs with VF3
Addanki et al. Placeto: Learning generalizable device placement algorithms for distributed machine learning
KR102523472B1 (en) Method and apparatus for searching new material
CN112579477A (en) Defect detection method, device and storage medium
US10900328B2 (en) Computer implemented method for generating a field development plan (FDP) for the exploitation of oil and gas reservoirs
CN109214191A (en) A method of utilizing deep learning forecasting software security breaches
Abseher et al. Improving the efficiency of dynamic programming on tree decompositions via machine learning
Mariani et al. OSCAR: An optimization methodology exploiting spatial correlation in multicore design spaces
Wessing et al. Niching by multiobjectivization with neighbor information: Trade-offs and benefits
CN105452598B (en) The method for selecting and optimizing the oil field control for yield platform
Liu et al. Extracting knowledge from web text with monte carlo tree search
Klarner et al. Parameter identification and model ranking of thomas networks
CN109670255B (en) Typical simulation condition recommendation method for time sequence parameter clustering
Mu et al. Multi-objective ant colony optimization algorithm based on decomposition for community detection in complex networks
Xie et al. Origin-based algorithms for traffic assignment: algorithmic structure, complexity analysis, and convergence performance
CN105260742A (en) Unified classification method for multiple types of data and system
CN106372458A (en) Critical protein identification method based on NCCO (Neighbor Closeness Centrality and Orthology) information
Zhou et al. Path constraint solving based test generation for hard-to-reach states
Reinhardt et al. Developing agent-based migration models in pairs
US20120290282A1 (en) Reachability analysis by logical circuit simulation for providing output sets containing symbolic values
Liu et al. An orthogonal predictive model-based dynamic multi-objective optimization algorithm
Andriushchenko et al. Search and explore: symbiotic policy synthesis in POMDPs
US20170039315A1 (en) Information processing apparatus and simulation method
Karmazin et al. Timing driven placement for quasi delay-insensitive circuits

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant