CN106528433B - A kind of priorities of test cases sort method for white-box testing - Google Patents

A kind of priorities of test cases sort method for white-box testing Download PDF

Info

Publication number
CN106528433B
CN106528433B CN201611140362.6A CN201611140362A CN106528433B CN 106528433 B CN106528433 B CN 106528433B CN 201611140362 A CN201611140362 A CN 201611140362A CN 106528433 B CN106528433 B CN 106528433B
Authority
CN
China
Prior art keywords
sequence
individual
population
sentence
test case
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201611140362.6A
Other languages
Chinese (zh)
Other versions
CN106528433A (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.)
Xi'an Zhonglang Intelligent Control Technology Co.,Ltd.
Original Assignee
Xian University of Posts and Telecommunications
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xian University of Posts and Telecommunications filed Critical Xian University of Posts and Telecommunications
Priority to CN201611140362.6A priority Critical patent/CN106528433B/en
Publication of CN106528433A publication Critical patent/CN106528433A/en
Application granted granted Critical
Publication of CN106528433B publication Critical patent/CN106528433B/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/3676Test management for coverage analysis
    • 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)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biophysics (AREA)
  • Health & Medical Sciences (AREA)
  • General Physics & Mathematics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Evolutionary Biology (AREA)
  • Quality & Reliability (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Computer Hardware Design (AREA)
  • Genetics & Genomics (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Biomedical Technology (AREA)
  • Artificial Intelligence (AREA)
  • Physiology (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

For the priorities of test cases sequencing problem in white-box testing, the invention discloses a kind of priorities of test cases sort methods for white-box testing.This method first encodes individual on the basis of sentence set covering theory, generates initial population at random, and cover average percent as fitness function using sentence;Then, population of new generation is generated by selection, intersection and mutation operation, individual is evaluated using fitness function, record the maximum adaptation value in iteration and its corresponding individual;Finally, when iterations reach maximum iteration, the corresponding individual of maximum adaptation value is optimal sequencing result.Compared with existing method, the present invention provides a kind of fast convergence rate, stability good priorities of test cases sort method, and this method helps to find software defect as early as possible during white-box testing, reduces testing cost.

Description

A kind of priorities of test cases sort method for white-box testing
Technical field
The invention belongs to white-box testing technical fields in software testing technology field, especially software test, and in particular to A kind of priorities of test cases sort method for white-box testing.
Background technology
Priorities of test cases ordering techniques refer to by specific ranking criteria, to owning for a certain program to be measured Test case is ranked up, it is therefore an objective to the covering object in program to be measured, such as sentence is covered at faster speed, to accelerate The defects detection rate of test case.Genetic algorithm is a kind of by simulating biological genetic evolution process in nature, to most The method that the optimal solution of optimization problem scans for, it has when solving some challenges such as function optimization, dispersed problem Good application value, meanwhile, the use of genetic algorithm does not depend on the specific field of problem, therefore has to the type of problem very strong Robustness.
Priorities of test cases sequencing problem is a research hotspot in current software test field, for the problem Research was carried out by Wrong et al. in 1997 earliest, their binding test use-case history coverage informations and code revision information carry Go out a kind of mixed method, this method identifies redundancy testing use-case by reduction technology for test use cases first, is surveyed to nonredundancy Example on probation is ranked up according to its covering power.2007, Li Zheng et al. was directed to priorities of test cases problem by traditional something lost Propagation algorithm has carried out contrast verification with greedy algorithm, hill-climbing algorithm, and experiment confirms to do priorities of test cases using genetic algorithm Better result in most cases can be obtained than other algorithms.2015, Zhang Weixiang et al. was proposing two kinds of tests Priorities of test cases sequence is carried out using genetic algorithm on the basis of use-case priority evaluation index, achieves preferable experiment Effect.2016, Lu Yafeng et al. was by calculating the corresponding test use cases of 8 large scale industry program different editions using greed Method, adaptively stochastic algorithm and genetic algorithm are ranked up, and experimental verification adaptive algorithm and genetic algorithm can obtain ratio Other better ranking results of algorithm.However, that there are convergence rates in searching process is slow for traditional genetic algorithm, stability is not Good problem, for this purpose, the present invention based on traditional genetic algorithm, is improved selection therein and crossover operation, carries A kind of new priorities of test cases sort method for white-box testing is gone out, has improved testing efficiency, contribute to software defect Discovery as early as possible.
Invention content
In regression test, carry out white-box testing when will from it is a large amount of can be used test case in choose it is important, take off wrong energy The strong test case preferential treatment ranging sequence of power is tested, and to improve the ability for finding defect in test process, is at this moment needed The execution order of test case is planned again, achievees the purpose that improve testing efficiency.Traditional genetic algorithm is being found There is a problem of that convergence rate is slow, stability is poor during the best sequence of test case, therefore is used for there is an urgent need for seeking one kind The new method of priorities of test cases sequence.
The technical scheme is that:A kind of priorities of test cases sort method for white-box testing specifically includes Following steps:
Step 1:For a program to be measured, tested using designed test use cases, by test case The sentence coverage condition for treating ranging sequence is recorded, and the sentence coverage information matrix A that test case treats ranging sequence is obtained;It is false If certain program to be measured has m sentence, tested with n test case, if test use cases are indicated with Φ, Φ={ T1, T2,…,Ti,…,Tn, wherein Ti(1≤i≤n) is i-th of test case that test case is concentrated, the sentence covering letter of construction The size of matrix A is ceased for n × m, the range of statement number is 1 to m in program to be measured, and the range of test case number is 1 to n, If i-th of test case covers j-th of sentence in executing, then Aij=1, otherwise Aij=0;
Step 2:Coding;Priorities of test cases sequencing problem is for given program to be measured and test use cases, individual Indicate that a priorities of test cases collating sequence, priorities of test cases collating sequence are exactly to be made of test case number Ordered sequence, i.e. each individual is encoded as an orderly test case number string, and the length of coding is test case Number n;
Step 3:Construct fitness function;For any individual, TSvIt can be covered in program to be measured to be first V-th of sentence SvTest case order residing in sequence is executed in the test case, it is assumed that after having executed test The quantity for the sentence being capped in program to be measured is M, then M sentence corresponds to M such order, the sum of institute's orderliness isIt is possible thereby to constructing fitness function APSC, APSC indicates the average percent of sentence covering,I.e.Its Middle TSv(1≤v≤M) can be calculated with sentence coverage information matrix A, for capped sentence Sv, first is searched in A A test case for covering sentence order residing in the test case sequence, then this order is exactly TSvNumber Value;
Step 4:Random initializtion population;Population scale is set as N, i.e., includes individual in population, if indicating to plant with D Group, then D=<r11,r12,…,r1n>,<r21,r22,…,r2n>,…,<rw1,rw2,…,rwn>,…,<rN1,rN2,…,rNn>, Wherein<rw1,rw2,…,rwn>Represent w-th of individual in population;Crossover probability P is setcWith mutation probability PmAnd greatest iteration Number MAX;Iterations g=1 is enabled, iteration is started;
Step 5:Execute random sampling selection strategy;
(1) adaptive value for calculating all individuals in population, obtains an array being made of N number of adaptive value, is expressed as {Fitness1,Fitness2,…,FitnessN, wherein Fitnessindividual(1≤individual≤N) is indicated in population The adaptive value of i-th ndividual individual, if the average value of Population adaptation value is indicated with averageFitness,Real number start (0 < is generated at random Start < averageFitness);Enable index=1, index indicates individual number, enables the sum of Population adaptation value sum initial values be Fitness1
(2) it is the quantity for the individual currently having been selected to enable select;Calculating pointer=start+select × AverageFitness, pointer are the foundation for weighing individual fitness size in population, if Fitnessindex< pointer, So proceed as follows:A.index=index+1, sum=sum+Fitnessindex;B. the operation in a is repeated, when When sum >=pointer, the value of index is stored in the select+1 position in individuals arrays, and stop in b Operation;
(3) select=select+1 repeats the operation in (2), as select=N, stops selection operation;
(4) it using the number in individuals arrays as subscript, is sequentially replaced with each corresponding individual of these subscripts Each individual in current population is changed, population of new generation identical with former Population Size is obtained;
Step 6:Execute crossover operation;For any two individual A in population1And A2If Assuming that the offspring individual generated after crossover operation is A1' and A2';One 0 to 1 is generated at random Real number works as PcWhen more than this real number, crossover operation is executed, the offspring individual substitution parent individuality generated after crossover operation enters New population, the individual not intersected are directly copied into new population;The detailed process of crossover operation is as follows:
(1) A is calculated1And A2The different number of positions of numerical value in middle same position, it is assumed that be t, then A1And A2Middle same position The identical number of positions of upper numerical value is n-t;
(2) N number of sequence is generated, each sequence is the arrangement that a length is t, and k-th of sequence can indicate in N number of sequence ForWherein K=1,2 ..., N, 1≤u≤t,<ru×k>Expression takes ru× k's Negative is added 1, the negative is made to become a positive number, wherein r by fractional part if fractional part is negativeu=2cos (2 π u/q), q is the least prime for meeting q >=2t+3;
(3) A is deleted1And A2In n-t same position on identical numerical value, by the difference in remaining t same position Numerical value is ranked up according to ascending sequence, and the sequence being made of t numerical value after note sequence is s, s=< s1,s2,…, sh,…,st>, wherein s1≤s2≤…≤sh≤…≤st(1≤h≤t);It willAccording to by It is small to it is big be ranked sequentially forRemember that the sequence is Pk';RecordIn P after sequencekThe location of in ', according to the situation of change of position to shResiding in s Position is readjusted, and is obtained by s1,s2,…,stOne new sequence of composition, is denoted as s ', reuses each in s ' Numerical value fills A respectively1And A2The t position with different numerical value, has just obtained a new sequence, has been denoted as in middle same position Sk, which is n;When k takes 1,2 ..., when each numerical value in N-1, N, it is carried out aforesaid operations in (3), so that it may with The sequence that N number of length is n is generated, S={ S are denoted as1,S2,…,SN};
(4) adaptive value of the N number of sequence generated in (3), A are calculated1' and A2Numerical value and adaptive value in ' on each position are most Numerical value in big sequence on each position corresponds to identical;
Step 7:Execute mutation operation;
For any one individual in population, it is assumed that be B, the random real number for generating one 0 to 1 works as PmMore than this reality When number, mutation operation is executed to B, the process of mutation operation is:Two positions are randomly choosed from B, it will be on the two positions Numerical value swaps, to obtain a new individual B ';
Step 8:Record the maximum adaptation value after current iteration and its corresponding individual;
Step 9:Judge stopping criterion for iteration, the stopping criterion for iteration in this method is that current iteration number is more than maximum Iterations MAX, if end condition is set up, the corresponding priorities of test cases of maximum adaptation value individual sorts sequence at this time It is classified as optimal priorities of test cases collating sequence, export the sequence and stops iteration;Otherwise, iterations g=g+1 is enabled, is returned Step 5 is returned, iteration is continued.
Advantageous effect of the present invention
The mode that selection operation in invention for priorities of test cases sequence uses random sampling selects satisfaction The mode of the several body of Population Size, this selection individual increases the probability chosen and have higher adaptive value individual in population, Ensure that can choose in population preferably individual in the selection process, increase convergence rate of the algorithm in searching process; Crossover operation, which considers two individuals intersected and has on which position on identical numerical value and which position, different numbers Value, reduces the blindness of crossover operation, increases convergence rate and stability of the algorithm in searching process;Experimental result is aobvious To show (shown in Fig. 2 and Fig. 3), it is good that this method generates the fast convergence rate of optimal priorities of test cases ranking results, stability, Testing efficiency can be improved, testing cost is saved, finds software defect early.
Description of the drawings
Attached drawing 1 is a kind of flow chart of priorities of test cases sort method for white-box testing.
Attached drawing 2 is that the average adaptive value of priorities of test cases sequence distinct methods changes comparison diagram.
Attached drawing 3 is the maximum adaptation value babinet figure of priorities of test cases sequence distinct methods.
Specific implementation mode
By taking the sequence of the priorities of test cases of the source program of JavaScript unit test frame Jasmine as an example, in conjunction with Attached drawing 1 carries out a kind of specific implementation mode of priorities of test cases sort method for white-box testing proposed by the present invention Explanation.
Step 1:For a program to be measured, tested using designed test use cases, by test case The sentence coverage condition for treating ranging sequence is recorded, and the sentence coverage information matrix A that test case treats ranging sequence is obtained; The source program of Jasmine has 292 sentences, is tested with 24 test cases, if test use cases are indicated with Φ, Φ= {T1, T2..., Ti..., Tn, wherein Ti(1≤i≤n) is i-th of test case that test case is concentrated, the sentence covering of construction The size of information matrix A is 24 × 292, and the range of statement number is 1 to 292 in program to be measured, the range of test case number It is 1 to 24, if i-th of test case covers j-th of sentence, A in executingij=1, otherwise Aij=0;
Step 2:Coding;Test Case Prioritization problem indicates one for given program to be measured and test use cases, individual A priorities of test cases collating sequence, priorities of test cases collating sequence are exactly that test case numbers the orderly sequence formed Row, i.e. each individual are encoded as an orderly test case number string, and the length of coding is the number 24 of test case;
Step 3:Construct fitness function;For any individual, TSvIt can be covered in program to be measured v-th to be first Sentence SvTest case order residing in sequence is executed in the test case, executed the source program of Jasmine after test In the quantity of sentence that is capped be 292, then 292 sentences correspond to 292 such order, the sum of institute's orderliness isIt is possible thereby to constructing fitness function APSC, APSC indicates the average percent of sentence covering,I.e. Wherein TSv(1≤v≤292) can be calculated using sentence coverage information matrix A, for capped sentence Sv, looked into A The order for looking for first test case for covering the sentence residing in the test case sequence, then this order is exactly TSvNumerical value;
Step 4:Random initializtion population;Population scale is set as 150, i.e., includes 150 individuals in population, if with D tables Show population, then D=<r11,r12,…,r124>,<r21,r22,…,r224>,…,<r1501,r1502,…,r15024>, wherein<r11, r12,…,r124>The 1st individual in population is represented,<r21,r22,…,r224>The 2nd individual ... in population is represented,< r1501,r1502,…,r15024>Represent the 150th individual in population;Crossover probability P is setc=0.85, mutation probability Pm= 0.55, maximum iteration MAX=50;Iterations g=1 is enabled, iteration is started;
Step 5:Execute random sampling selection strategy;
(1) adaptive value for calculating all individuals in population, obtains an array being made of 150 adaptive values, is expressed as {Fitness1,Fitness2,…,Fitness150, wherein Fitnessindividual(1≤individual≤150) indicate kind The adaptive value of i-th ndividual individual in group, in initial population the adaptive value of all individuals for (0.677226, 0.68764263,0.68707186,0.6705194,0.6021689,…,0.75742006,0.7020548,0.70719177, 0.7126141,0.63313353,0.7255993) if the average value of Population adaptation value is indicated with averageFitness,That is averageFitness= 103.31777662038803/150=0.6887851774692535;A real number start (0 < start < is generated at random AverageFitness), numerical value 0.36970036874340495;It enables index=1, index indicate individual number, enables kind The sum of group's adaptive value sum initial values are Fitness1, sum=Fitness1=0.677226;
(2) it is the quantity for the individual currently having been selected to enable select;Calculating pointer=start+select × AverageFitness, i.e. pointer=0.36970036874340495+0 × 0.6887851774692535, pointer are Evaluate the measurement foundation of individual fitness size in population, result of calculation 0.36970036874340495, due to sum> Pointer, so the numerical value 1 of index at this time is stored in the 1st position in array individuals, expression has selected kind The individual that number is 1 in group;
(3) select=select+1, at this time pointer=0.36970036874340495+1 × 0.6887851774692535, result of calculation 1.058485546212658, due to sum at this time preserve be select=0 when Numerical value 0.677226 final sum, is compared sum and pointer, 0.677226<1.058485546212658 so Index=index+1=2, sum=sum+Fitness2=0.677226+0.68764263=1.36486863;Compare again Sum and pointer, due to 1.36486863 > 1.058485546212658, so the numerical value 2 of index at this time is stored in number The 2nd position in group individuals;The aforesaid operations in (3) are repeated, as select=N, stop selection behaviour Make;Such as:Value in certain iterative process after the completion of selection operation in individuals arrays is:(1,2,3,4,5,6,7,9, 10,11,12,13,14,15,16,17,18,19,20,21,22,22,23,24,26,27,28,28,31,32,33,34,35, 36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,52,53,54,55,55,56,57,58,59,60, 61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85, 86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107, 108,109,110,111,112,113,114,115,116,117,119,120,121,122,122,123,124,125,126, 127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145, 146,147,148,149,150),
As can be seen that individual in the selection process without selected, the table that number is 8,25,29,30 from data above These bright individual fitnesses are small, thus selected probability is smaller;The individual that number is 22,28,55,122 is in the selection process It has been selected repeatedly, has shown that these individual fitnesses are big, thus selected probability is big;
(4) it using the number in individuals arrays as subscript, is sequentially replaced with each corresponding individual of these subscripts Each individual in current population is changed, population of new generation identical with former Population Size is obtained;
Step 6:For any two individual A in population1And A2If Assuming that the offspring individual generated after crossover operation is A1' and A2';It is random to generate one 0 to 1 Real number, the random number generated here be 0.53896, due to PcMore than this real number, therefore execute crossover operation, crossover operation The offspring individual substitution parent individuality generated afterwards enters new population, and the individual not intersected is directly copied into new population; The detailed process of crossover operation is as follows:
(1) two parent individualities selected in this example are:A1=(17,1,5,15,3,14,20,22,10,23,4,16, 2,6,13,18,11,7,9,12,19,21,8,24);A2=(19,12,7,20,13,9,2,11,1,22,8,6,3,4,23,18, 15,10,17,21,14,16,5,24);Then A1And A2Numerical value different number of positions t=22, A in middle same position1And A2Middle phase The identical number of positions n-t=2 with numerical value on position;
(2) 150 sequences are generated, it is 22 arrangement that each sequence pair, which answers a length, and k-th of sequence can in N number of sequence To be expressed asWherein K=1,2 ..., 150,1≤u≤22;<ru×k>Expression takes ruNegative is added 1, the negative is made to become a positive number, wherein r by the fractional part of × k if fractional part is negativeu= 2cos (2 π u/q), q is the least prime for meeting q >=2t+3, here q >=2t+3=47, thus q takes 47, for example, work as u=3, k When=1, r3× 1=1.9289383501087531, then<r3×1>=0.9289383501087531;Work as u=4, when k=1, r4× 1=-6.482505539488857,<r4×1>=-0.482505539488857, then will<r4×1>Numerical value turn Become<r4×1>=-0.482505539488857+1, i.e., 0.5174944605111431;As k=2, it is obtained by calculation P2For (0.9643,0.8579,0.6826,0.4416,0.1392,0.7808,0.3727,0.9223,0.4376,0.9273, 0.4004,0.8663,0.3347,0.8149,0.3163,0.8477,0.4175,0.0334,0.7022,0.4299,0.2213, 0.0802);
(3) A is deleted1And A2In 2 same positions on identical numerical value, the numerical value deleted here be A1And A2In the 16th The numerical value 24 on numerical value 18 and the 24th position on a position;By the different numerical value in remaining 22 same positions according to Ascending sequence is ranked up, and the sequence being made of 22 numerical value after note sequence is indicated with s, s=<s1,s2,…,s22 >, wherein s1≤s2≤…≤s22, s=here<1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20, 21,22,23>;It willAccording to it is ascending be ranked sequentially forRemember that the sequence is Pk', here by P2In all numerical value according to ascending Sequence be ranked up, obtain (0.0334,0.0802,0.1392,0.2213,0.3163,0.3347,0.3727,0.4004, 0.4175,0.4299,0.4376,0.4416,0.6826,0.7022,0.7808,0.8149,0.8477,0.8579,0.8663, 0.9223,0.9273,0.9643);RecordIn P after sequencekThe location of in ', according to position The situation of change set is to siIt is readjusted, is obtained by s the location of in s1,s2,…,s22One new sequence of composition Row, are denoted as s ', such as P2In the numerical value 0.9643 of the 1st position become for 22, then by the 1st in s by its position of sorting Numerical value 1 on position is stored in the 22nd position of the new sequence that length is 22, P2In the numerical value 0.8579 of the 2nd position pass through The change of its position sort for 18, then the numerical value 2 in s on the 2nd position is stored in the 18th of the new sequence that length is 22 Position ..., P2In the numerical value 0.0802 of the 22nd position become for 2 by its position of sorting, then will be in s on the 22nd position Numerical value 23 be stored in length be 22 new sequence the 2nd position, by which to P2In 22 numerical value institute in the sequence The position at place obtained after being readjusted (19,23,5,22,15,13,7,11,17,21,9,4,3,20,6,14,16,2,12, 8,10,1), i.e., this is obtained by s1,s2,…,stOne new sequence of composition, each numerical value reused in the sequence are suitable Secondary filling A1And A222 positions with different numerical value, have just obtained a new sequence, have been denoted as S in middle same position2, should Sequence length is 24, S2=(19,23,5,22,15,13,7,11,17,21,9,4,3,20,6,18,14,16,2,12,8,1 0, 1,24);When k takes 1,2 ..., when each numerical value in 149,150, it is carried out aforesaid operations in (3), so that it may to generate 150 The sequence that length is 24, is denoted as S={ S1,S2,…,S150};
(4) adaptive value of 150 sequences generated in (3), A are calculated1' and A2Numerical value and adaptive value in ' on each position Numerical value in maximal sequence on each position corresponds to identical;Here the maximum adaptation value in 150 sequences being calculated is 0.74999994, corresponding sequence be (9,12,4,19,8,15,5,6,24,10,13,17,21,1,11,18,7,22,16,3, , thus A 2,14,20,23)1' and A2' be (9,12,4,19,8,15,5,6,24,10,13,17,21,1,11,18,7,22, 16,3,2,14,20,23);
Step 7:Execute mutation operation;
For any one individual in population, it is assumed that be B, the random real number for generating one 0 to 1 works as PmMore than this reality When number, mutation operation is executed to B, the process of mutation operation is:Two positions are randomly choosed from B, it will be on the two positions Numerical value swaps, to obtain a new individual B ';For example, in population certain individual B, B=(4,16,19,24, 1,8,20,17,13,5,12,14,18,7,11,10,9,3,22,2,15,6,21,23) one 0 to 1 real number, generated at random It is 0.5114276945945321, meets 0.55 > 0.5114276945945321, executes mutation operation:It is randomly choosed from B Two positions be 7 and 11, the numerical value on the two positions is swapped to obtain a new individual B ', B '=(4,16, 19,24,1,8,12,17,13,5,20,14,18,7,11,10,9,3,22,2,15,6,21,23);
Step 8:Record the maximum adaptation value after current iteration and its corresponding individual, the maximum adaptation after current iteration Value be 0.78224885, the adaptive value it is corresponding individual for (4,19,8,5,15,9,24,12,13,17,3,7,6,16,11,14, 10,22,2,20,18,21,1,23);
Step 9:Judge stopping criterion for iteration, the stopping criterion for iteration in this method is that current iteration number is more than maximum Iterations MAX, MAX=50, if end condition is set up, the priorities of test cases collating sequence obtained at this time is most Excellent priorities of test cases collating sequence exports the sequence and stops iteration;Otherwise, iterations g=g+1, return to step are enabled Five, continue iteration.For example, after the 50th iteration, maximum adaptation value is 0.79723173 in population, the optimal test case of output Priority ranking sequence be (13,20,9,15,8,4,1,16,6,10,3,5,24,7,19,2,12,11,22,21,18,17,14, 23)。
It may be implemented to sort for the priorities of test cases of white-box testing by above procedure, for jasmine programs Sentence coverage information, respectively by traditional genetic algorithm and the present invention in method respectively execute 20 times.
Fig. 2 is in 20 experiments, and the adaptive value average value of 50 iteration is with iterations variation diagram.Figure it is seen that In iterative process, the adaptive value of this method is greater than the corresponding adaptive value of traditional genetic algorithm, so in white-box testing Priorities of test cases sorts, and this method has faster convergence rate compared to traditional genetic algorithm.
Fig. 3 is the babinet figure of maximum adaptation value in 20 experiments of traditional genetic algorithm and this method, compares two auxiliary box body figures It is found that the data distribution that this method obtains more is concentrated, i.e., it is preferential in the test case for using this method be directed to white-box testing The stability that optimal sequencing result is generated when grade sequence is more preferable.
Instance analysis shows that the priorities of test cases sort method proposed by the present invention for white-box testing is lost with tradition Propagation algorithm does priorities of test cases sequence and compares, provided by the present invention for the priorities of test cases sequence side of white-box testing Method fast convergence rate, the stability for generating optimal priorities of test cases collating sequence is good, is that one kind being effectively used for whitepack survey The priorities of test cases sort method of examination.

Claims (1)

1. a kind of priorities of test cases sort method for white-box testing, it is characterised in that including following steps:
Step 1:For a program to be measured, is tested using designed test use cases, test case is treated The sentence coverage condition of ranging sequence is recorded, and the sentence coverage information matrix A that test case treats ranging sequence is obtained;Assuming that certain Program to be measured has m sentence, is tested with n test case, if test use cases are indicated with Φ, Φ={ T1,T2,…, Ti,…,Tn, wherein Ti(1≤i≤n) is i-th of test case that test case is concentrated, the sentence coverage information matrix A of construction Size be n × m, the range of statement number is 1 to arrive m in program to be measured, the range of test case number be 1 arrive n, if i-th Test case covers j-th of sentence in executing, then Aij=1, otherwise Aij=0;
Step 2:Coding;Priorities of test cases sequencing problem is indicated for given program to be measured and test use cases, individual One priorities of test cases collating sequence, priorities of test cases collating sequence are exactly to be had by what test case number was formed Sequence sequence, i.e. each individual are encoded as an orderly test case number string, and the length of coding is the number of test case n;
Step 3:Construct fitness function;For any individual, TSvV-th of sentence in program to be measured can be covered to be first SvTest case order residing in sequence is executed in the test case, it is assumed that executed and be capped in program to be measured after test The quantity of sentence be M, then M sentence corresponds to M it is a as order, the sum of institute's orderliness isIt is possible thereby to structure It makes fitness function APSC, APSC and indicates the average percent of sentence covering,
I.e.Wherein TSv(1≤v≤M) can be counted with sentence coverage information matrix A It calculates, for capped sentence Sv, first test case for covering the sentence is searched in A in the test case sequence Residing order, then this order is exactly TSvNumerical value;
Step 4:Random initializtion population;Population scale is set as N, i.e., includes individual in population, if indicating population with D, Then
D=<r11,r12,…,r1n>,<r21,r22,…,r2n>,…,<rw1,rw2,…,rwn>,…,<rN1,rN2,…,rNn>, In<rw1,rw2,…,rwn>Represent w-th of individual in population;Crossover probability P is setcWith mutation probability PmAnd greatest iteration time Number MAX;Iterations g=1 is enabled, iteration is started;
Step 5:Execute random sampling selection strategy;
(1) adaptive value for calculating all individuals in population, obtains an array being made of N number of adaptive value, is expressed as {Fitness1,Fitness2,…,FitnessN, wherein Fitnessindividual(1≤individual≤N) is indicated in population The adaptive value of i-th ndividual individual, if the average value of Population adaptation value is indicated with averageFitness,Real number start (0 < is generated at random Start < averageFitness);Enable index=1, index indicates individual number, enables the sum of Population adaptation value sum initial values be Fitness1
(2) it is the quantity for the individual currently having been selected to enable select;Calculating pointer=start+select × AverageFitness, pointer are the foundation for weighing individual fitness size in population, if Fitnessindex< pointer, So proceed as follows:A.index=index+1, sum=sum+Fitnessindex;B. the operation in a is repeated, when When sum >=pointer, the value of index is stored in the select+1 position in individuals arrays, and stop in b Operation;
(3) select=select+1 repeats the operation in (2), as select=N, stops selection operation;
(4) it using the number in individuals arrays as subscript, is sequentially replaced and is worked as with each corresponding individual of these subscripts Each individual in preceding population obtains population of new generation identical with former Population Size;
Step 6:Execute crossover operation;For any two individual A in population1And A2If Assuming that the offspring individual generated after crossover operation is A1' and A2';It is random to generate one 0 to 1 Real number, work as PcWhen more than this real number, execute crossover operation, the offspring individual generated after crossover operation replace parent individuality into Enter new population, the individual not intersected is directly copied into new population;The detailed process of crossover operation is as follows:
(1) A is calculated1And A2The different number of positions of numerical value in middle same position, it is assumed that be t, then A1And A2Number in middle same position It is n-t to be worth identical number of positions;
(2) N number of sequence is generated, each sequence is the arrangement that a length is t, and k-th of sequence can be expressed as in N number of sequenceWherein K=1,2 ..., N, 1≤u≤t,<ru×k>Expression takes ru× k's Negative is added 1, the negative is made to become a positive number, wherein r by fractional part if fractional part is negativeu=2cos (2 π u/q), q is the least prime for meeting q >=2t+3;
(3) A is deleted1And A2In n-t same position on identical numerical value, by the different numerical value in remaining t same position It is ranked up according to ascending sequence, the sequence being made of t numerical value after note sequence is s, s=< s1,s2,…,sh,…, st>, wherein s1≤s2≤…≤sh≤…≤st(1≤h≤t);It willAccording to ascending Be ranked sequentially forRemember that the sequence is Pk';Record In P after sequencekThe location of in ', according to the situation of change of position to shIt is readjusted the location of in s, It obtains by s1,s2,…,stOne new sequence of composition, is denoted as s ', each numerical value reused in s ' fills A respectively1And A2 The t position with different numerical value, has just obtained a new sequence, has been denoted as S in middle same positionk, which is n; When k takes 1,2 ..., when each numerical value in N-1, N, it is carried out aforesaid operations in (3), so that it may to generate N number of length as n's Sequence is denoted as S={ S1,S2,…,SN};
(4) adaptive value of the N number of sequence generated in (3), A are calculated1' and A2Numerical value in ' on each position and adaptive value maximum sequence Numerical value in row on each position corresponds to identical;
Step 7:Execute mutation operation;
For any one individual in population, it is assumed that be B, the random real number for generating one 0 to 1 works as PmWhen more than this real number, Mutation operation is executed to B, the process of mutation operation is:From B randomly choose two positions, by the numerical value on the two positions into Row exchanges, to obtain a new individual B ';
Step 8:Record the maximum adaptation value after current iteration and its corresponding individual;
Step 9:Judge stopping criterion for iteration, the stopping criterion for iteration in this method is that current iteration number is more than greatest iteration Number MAX, if end condition is set up, the corresponding priorities of test cases collating sequence of maximum adaptation value individual is at this time Optimal priorities of test cases collating sequence exports the sequence and stops iteration;Otherwise, iterations g=g+1 is enabled, step is returned Rapid five, continue iteration.
CN201611140362.6A 2016-12-12 2016-12-12 A kind of priorities of test cases sort method for white-box testing Active CN106528433B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611140362.6A CN106528433B (en) 2016-12-12 2016-12-12 A kind of priorities of test cases sort method for white-box testing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611140362.6A CN106528433B (en) 2016-12-12 2016-12-12 A kind of priorities of test cases sort method for white-box testing

Publications (2)

Publication Number Publication Date
CN106528433A CN106528433A (en) 2017-03-22
CN106528433B true CN106528433B (en) 2018-10-02

Family

ID=58341930

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611140362.6A Active CN106528433B (en) 2016-12-12 2016-12-12 A kind of priorities of test cases sort method for white-box testing

Country Status (1)

Country Link
CN (1) CN106528433B (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107145961A (en) * 2017-03-24 2017-09-08 南京邮电大学 A kind of tour schedule planing method based on improved adaptive GA-IAGA
CN109271320B (en) * 2017-11-07 2021-09-24 西安邮电大学 Higher-level multi-target test case priority ordering method
JP6897524B2 (en) 2017-11-29 2021-06-30 トヨタ自動車株式会社 Software quality judgment device, software quality judgment method, and software quality judgment program
CN107844427A (en) * 2017-11-29 2018-03-27 郑州云海信息技术有限公司 A kind of Test Case Prioritization method perceived based on test resource
JP6891780B2 (en) * 2017-11-29 2021-06-18 トヨタ自動車株式会社 Software quality judgment device, software quality judgment method, and software quality judgment program
CN109871311B (en) * 2017-12-04 2022-12-27 北京京东尚科信息技术有限公司 Method and device for recommending test cases
CN109783349B (en) * 2018-12-10 2022-02-15 江苏大学 Test case priority ranking method and system based on dynamic feedback weight
CN110059015B (en) * 2019-04-28 2022-09-30 西安邮电大学 Method for sequencing priorities of population evolution multi-target test cases
CN110502447B (en) * 2019-08-30 2022-10-25 西安邮电大学 Regression test case priority ordering method based on graph
CN113742206A (en) * 2020-05-27 2021-12-03 南京大学 Test case priority algorithm selection method based on project characteristics
CN113128556B (en) * 2021-03-10 2022-10-28 天津大学 Deep learning test case sequencing method based on mutation analysis
CN114153742A (en) * 2021-12-10 2022-03-08 深圳前海微众银行股份有限公司 Unit testing method, unit testing device, electronic equipment and storage medium
CN114978974B (en) * 2022-05-20 2023-09-19 国网重庆市电力公司电力科学研究院 Wireless communication module testing method, device, equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102253889A (en) * 2011-08-07 2011-11-23 南京大学 Method for dividing priorities of test cases in regression test based on distribution
CN102289719A (en) * 2011-07-25 2011-12-21 南京信息工程大学 Orthogonal wavelet blind equalization method based on optimization of simulated annealing genetic algorithm (SA-GA-WTCMA)

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9489289B2 (en) * 2014-12-09 2016-11-08 Sap Se Adaptive framework automatically prioritizing software test cases

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102289719A (en) * 2011-07-25 2011-12-21 南京信息工程大学 Orthogonal wavelet blind equalization method based on optimization of simulated annealing genetic algorithm (SA-GA-WTCMA)
CN102253889A (en) * 2011-08-07 2011-11-23 南京大学 Method for dividing priorities of test cases in regression test based on distribution

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
"Time-Aware Test Suite Prioritization";Kristen R. Walcott 等;《ISSTA "06 Proceedings of the 2006 international symposium on Software testing and analysis》;20060720;第37卷(第9期);第1-12页 *
"一种基于遗传算法的测试用例优先排序方法";张卫祥 等;《小型微型计算机系统》;20150930;第36卷(第9期);第1998-2002页 *
"多目标测试用例预优化方法及其在GPU上的应用研究";程俊;《万方数据知识服务平台》;20121130;第四章 *

Also Published As

Publication number Publication date
CN106528433A (en) 2017-03-22

Similar Documents

Publication Publication Date Title
CN106528433B (en) A kind of priorities of test cases sort method for white-box testing
Tang et al. Differential evolution with an individual-dependent mechanism
Shukla et al. Comparative review of selection techniques in genetic algorithm
CN104239213B (en) Two-stage scheduling method of parallel test tasks facing spacecraft automation test
CN104765690B (en) Embedded software test data generation method based on fuzzy genetic algorithm
CN109299142A (en) A kind of convolutional neural networks search structure method and system based on evolution algorithm
CN105844300A (en) Optimized classification method and optimized classification device based on random forest algorithm
CN102141958B (en) Method for evolving and generating path coverage test data facing defects
CN105929690B (en) A kind of Flexible Workshop Robust Scheduling method based on decomposition multi-objective Evolutionary Algorithm
CN106228183A (en) A kind of semi-supervised learning sorting technique and device
CN105825270A (en) Automatic test paper generation method for test questions in question bank through genetic algorithm
CN108510050A (en) It is a kind of based on shuffling the feature selection approach to leapfrog
CN108573274A (en) A kind of selective clustering ensemble method based on data stability
CN106156857A (en) The method and apparatus selected for mixed model
CN110096512A (en) Method for establishing item bank, device, facility for study and storage medium
CN111784084A (en) Travel generation prediction method, system and device based on gradient lifting decision tree
CN111325284A (en) Self-adaptive learning method and device based on multi-target dynamic distribution
CN107590538A (en) A kind of dangerous source discrimination based on online Sequence Learning machine
CN110210623A (en) Adaptive multiple target hybrid differential evolution algorithm based on simulated annealing and comentropy
CN110046811B (en) Knowledge point root-tracing and source-tracing method suitable for adaptive learning
CN104572868B (en) The method and apparatus of information matches based on question answering system
CN106096780A (en) The dissolved oxygen prediction method of ant group algorithm Optimized Least Square Support Vector
CN109934344A (en) A kind of multiple target Estimation of Distribution Algorithm of improved rule-based model
CN113221964B (en) Single sample image classification method, system, computer device and storage medium
Yan et al. A fast evolutionary algorithm for combinatorial optimization problems

Legal Events

Date Code Title Description
C06 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
TR01 Transfer of patent right

Effective date of registration: 20201228

Address after: Room 10701-7157, 7th floor, Ruiji building, No.15, Gaoxin 2nd Road, high tech Zone, Xi'an City, Shaanxi Province, 710075

Patentee after: Xi'an Zhonglang Intelligent Control Technology Co.,Ltd.

Address before: 710000 No. 563 Chang'an South Road, Xi'an City, Shaanxi Province

Patentee before: XI'AN University OF POSTS & TELECOMMUNICATIONS

TR01 Transfer of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: A Test Case Prioritization Method for White Box Testing

Granted publication date: 20181002

Pledgee: Bank of China Limited Xi'an High tech Development Zone Sub branch

Pledgor: Xi'an Zhonglang Intelligent Control Technology Co.,Ltd.

Registration number: Y2024980018481

PE01 Entry into force of the registration of the contract for pledge of patent right