CN106528433A - Testing case priority ranking method for white-box testing - Google Patents

Testing case priority ranking method for white-box testing Download PDF

Info

Publication number
CN106528433A
CN106528433A CN201611140362.6A CN201611140362A CN106528433A CN 106528433 A CN106528433 A CN 106528433A CN 201611140362 A CN201611140362 A CN 201611140362A CN 106528433 A CN106528433 A CN 106528433A
Authority
CN
China
Prior art keywords
sequence
population
individual
test case
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
CN201611140362.6A
Other languages
Chinese (zh)
Other versions
CN106528433B (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

The invention discloses a testing case priority ranking method for white-box testing to solve the problem of testing case priority ranking in white-box testing. The method includes the steps: firstly, encoding individuals based on a statement coverage matrix, randomly generating initial populations and taking a statement coverage mean average percentage as a fitness function; secondly, generating new-generation populations by selection, crossover and mutation operation, evaluating the individuals by the fitness function and recording the maximum fitness value in iteration and the corresponding individuals; finally, acquiring optimal ranking results of the individuals corresponding to the maximum fitness value when iteration times reach the maximum iteration time. Compared with an existing method, the testing case priority ranking method is high in convergence rate and good in stability, software defects in the white-box testing process can be discovered as early as possible, and testing cost can be reduced.

Description

A kind of priorities of test cases sort method for white-box testing
Technical field
The invention belongs to white-box testing technical field 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 are referred 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 cover the covering object in program to be measured, such as sentence, so as to accelerate at faster speed The defects detection speed of test case.Genetic algorithm is a kind of by simulating genetic evolution process biological in nature, to most The method that the optimal solution of optimization problem is scanned for, it has when some challenges such as function optimization, dispersed problem are solved Good using value, meanwhile, the use of genetic algorithm is independent of the specific field of problem, therefore the species to problem has very strong Robustness.
Priorities of test cases sequencing problem is a study hotspot in current software test field, for the problem Research is carried out in 1997 by Wrong et al. earliest, their binding test use-case history coverage informations and code revision information, carries Go out a kind of mixed method, the method identifies redundancy testing use-case by reduction technology for test use cases first, nonredundancy is surveyed Example on probation is ranked up according to its covering power.2007, Li Zheng et al. was for 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 In most of the cases more preferable result 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, preferably experiment is achieved Effect.2016, Lu Yafeng et al. by the corresponding test use cases of 8 large scale industry program different editions using greed calculation Method, adaptively stochastic algorithm and genetic algorithm are ranked up, and experimental verification adaptive algorithm and genetic algorithm can obtain ratio The more preferable ranking results of other algorithms.However, traditional genetic algorithm is present in searching process, convergence rate is slow, and stability is not Good problem, for this purpose, the present invention is based on traditional genetic algorithm, is improved to 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.
The content of the invention
In regression test, to choose from substantial amounts of available test case when carrying out white-box testing it is important, take off wrong energy The strong test case preferential treatment ranging sequence of power is tested, and to improve the ability that defect is found in test process, is at this moment needed The execution order of test case is planned again, the purpose for improving testing efficiency is reached.Traditional genetic algorithm is being found There is a problem of during the optimal sequence of test case that convergence rate is slow, stability is poor, therefore need badly and seek one kind and be used for 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 step:
Step one:For a program to be measured, tested using the test use cases for having designed, by test case The sentence coverage condition for treating ranging sequence is recorded, and obtains the sentence coverage information matrix A that test case treats ranging sequence;It is false If certain program to be measured there are m bar sentences, tested with n test case, if test use cases are represented with Φ, Φ={ T1, T2,…,Ti,…,Tn, wherein TiI-th test case that (1≤i≤n) is concentrated for test case, the sentence of construction cover letter The size of breath matrix A is n × m, and in program to be measured, the scope of statement number is 1 to m, and the scope of test case numbering is 1 to n, If i-th test case covers j-th sentence, A in performingij=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 A priorities of test cases collating sequence is represented, priorities of test cases collating sequence is exactly to be made up of test case numbering Ordered sequence, i.e. each individuality is encoded as an orderly test case numbering string, and the length of coding is test case Number n;
Step 3:Construction fitness function;For arbitrary individuality, TSjCan cover j-th in program to be measured for first Sentence SjThe order residing in the test case Perform sequence of test case, it is assumed that performed after test quilt in program to be measured The quantity of the sentence of covering is M, then M such order of M sentence correspondence, and institute's orderliness sum isIt is possible thereby to Construction fitness function APSC, APSC represent the average percent that sentence is covered,
I.e.Wherein TSj(1≤j≤M) can be carried out with sentence coverage information matrix A Calculate, for the sentence S being cappedj, first test case for covering the sentence is searched in A in the test case sequence In residing order, then this order is exactly TSjNumerical value;
Step 4:Random initializtion population;Population scale is set as N, i.e., individuality is included in population, if kind is represented with D Group, then
D=<r11,r12,…,r1n>,<r21,r22,…,r2n>,…,<ri1,ri2,…,rin>,…,<rN1,rN2,…,rNn >, wherein<ri1,ri2,…,rin>I-th represented in population is individual;Crossover probability P is setcWith mutation probability PmAnd it is maximum Iterationses MAX;Iterationses g=1 is made, starts iteration;
Step 5:Perform stochastic sampling selection strategy;
(1) all individual adaptive values in population are calculated, an array being made up of N number of adaptive value is obtained, is expressed as {Fitness1,Fitness2,…,FitnessN, wherein FitnessindividualDuring (1≤individual≤N) represents population I-th ndividual individual adaptive value, if the meansigma methodss of Population adaptation value are represented with averageFitness,Real number start (0 < is generated at random Start < averageFitness);Make index=1, index represent individual numbering, make the Population adaptation value sum sum initial value be Fitness1
(2) select is made to be the quantity for currently having been chosen by individuality;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 During sum >=pointer, the select+1 position value of index being stored in individuals arrays, and stop in b Operation;
(3) select=select+1, repeats the operation in (2), as select=N, stops selection operation;
(4) numeral in individuals arrays is sequentially replaced as subscript with corresponding each individuality of these subscripts Each changed in current population is individual, obtains and former Population Size identical a new generation population;
Step 6:Perform crossover operation;For any two individuality A in population1And A2If, The offspring individual produced after assuming crossover operation is A1' and A2';The random real number for generating 0 to 1, works as PcMore than this real number When, crossover operation is performed, the offspring individual produced after crossover operation replaces parent individuality to enter new population, is not intersected Individuality is directly copied into new population;The detailed process of crossover operation is as follows:
(1) calculate A1And A2The different number of positions of numerical value in middle same position, it is assumed that for t, then A1And A2Middle same position Upper numerical value identical number of positions is n-t;
(2) N number of sequence is produced, each sequence is the arrangement that a length is t, and k-th sequence can be represented in N number of sequence ForWherein
K=1,2 ..., N, 1≤u≤t,<ru×k>Expression takes ruThe fractional part of × k, if fractional part is negative, that Negative is added 1, makes the negative become a positive number, wherein ru=2cos (2 π u/q), q are the minimum elements for meeting q >=2t+3 Number;
(3) delete A1And 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 order, and the sequence being made up of t numerical value after note sequence is s, s=<s1,s2,…,st >, wherein s1≤s2≤…≤st;WillIt is arranged as according to ascending order Remember that the sequence is Pk';RecordIn P after sequencekLocation in ', according to the change of position Situation is to siIn s, location is readjusted, and is obtained by s1,s2,…,stOne new sequence of composition, is designated as S ', each numerical value reused in s ' fill A respectively1And A2There is in middle same position t position of different numerical value, must To a new sequence, S is designated ask, the sequence length is n;When k takes 1,2 ..., N-1, during each numerical value in N, holds Aforesaid operations in row (3), it is possible to generate the sequence that N number of length is n, be designated as S={ S1,S2,…,SN};
(4) adaptive value of the N number of sequence generated in calculating (3), A1' and A2Numerical value in ' on each position is with adaptive value most Numerical value correspondence in big sequence on each position is identical;
Step 7:Perform mutation operation;
For in population, any one is individual, it is assumed that for B, the random real number for generating 0 to 1, work as PmMore than this reality During number, mutation operation is performed to B, the process of mutation operation is:Two positions are randomly choosed from B, by the two positions Numerical value is swapped, so as to obtain a new individual B ';
Step 8:Maximum adaptation value and its corresponding individuality after record current iteration;
Step 9:Judge stopping criterion for iteration, the stopping criterion for iteration in this method is current iteration number of times more than maximum Iterationses MAX, if end condition is set up, then now the individual corresponding priorities of test cases of maximum adaptation value sorts sequence Optimum priorities of test cases collating sequence is classified as, the sequence is exported and is stopped iteration;Otherwise, iterationses g=g+1 is made, is returned Step 5 is returned, continues iteration.
Beneficial effect of the present invention
Selection operation in invention for priorities of test cases sequence employs the mode of stochastic sampling and selects satisfaction The several body of Population Size, the individual mode of this selection increase the probability for having higher adaptive value individual in choosing population, Ensure that, increased convergence rate of the algorithm in searching process; Crossover operation considers two individualities for being intersected and has on which position on identical numerical value and which position different numbers Value, reduces the blindness of crossover operation, increased convergence rate and stability of the algorithm in searching process;Experimental result shows Show (by shown in Fig. 2 and Fig. 3), this method generates the fast convergence rate of optimum priorities of test cases ranking results, good stability, Testing efficiency can be improved, testing cost is saved, is found software defect early.
Description of the drawings
Accompanying drawing 1 is a kind of flow chart of the priorities of test cases sort method for white-box testing.
Accompanying drawing 2 is the average adaptation value changes comparison diagram of priorities of test cases sequence distinct methods.
Accompanying drawing 3 is the maximum adaptation value casing figure of priorities of test cases sequence distinct methods.
Specific embodiment
By taking the priorities of test cases sequence of the source program of JavaScript unit test frame Jasmine as an example, with reference to Accompanying drawing 1 is carried out to a kind of specific embodiment of the priorities of test cases sort method for white-box testing proposed by the present invention Explanation.
Step one:For a program to be measured, tested using the test use cases for having designed, by test case The sentence coverage condition for treating ranging sequence is recorded, and obtains the sentence coverage information matrix A that test case treats ranging sequence; The source program of Jasmine has 292 sentences, is tested with 24 test cases, if test use cases are represented with Φ, Φ= {T1,T2,…,Ti,…,Tn, wherein TiI-th test case that (1≤i≤n) is concentrated for test case, the sentence of construction are covered The size of information matrix A is 24 × 292, and in program to be measured, the scope of statement number is 1 to 292, the scope of test case numbering It is 1 to 24, if i-th test case covers j-th sentence, A in performingij=1, otherwise Aij=0;
Step 2:Coding;Test Case Prioritization problem is for given program to be measured and test use cases, individual to represent one Individual priorities of test cases collating sequence, priorities of test cases collating sequence are exactly the orderly sequence constituted by test case numbering Row, i.e. each individuality are encoded as an orderly test case numbering string, and the length of coding is the number 24 of test case;
Step 3:Construction fitness function;For arbitrary individuality, TSjCan cover j-th in program to be measured for first Sentence SjThe order residing in the test case Perform sequence of test case, performed the source program of Jasmine after test In the quantity of sentence that is capped be 292, then 292 sentences, 292 such order of correspondence, institute's orderliness sum isIt is possible thereby to construct fitness function APSC, APSC represents the average percent that sentence is covered,
I.e.Wherein TSj(1≤j≤292) can be covered using sentence Information matrix A is calculated, for the sentence S being cappedj, first test case for covering the sentence is searched in A exist Residing order in the test case sequence, then this order is exactly TSjNumerical value;
Step 4:Random initializtion population;Population scale is set as 150, i.e., it is individual comprising 150 in population, if using D tables Show population, then
D=<r11,r12,…,r124>,<r21,r22,…,r224>,…,<r1501,r1502,…,r15024>, wherein<r11, r12,…,r124>The 1st represented in population is individual,<r21,r22,…,r224>The 2nd represented in population is individual ...,< r1501,r1502,…,r15024>The 150th represented in population is individual;Crossover probability P is setc=0.85, mutation probability Pm= 0.55, maximum iteration time MAX=50;Iterationses g=1 is made, starts iteration;
Step 5:Perform stochastic sampling selection strategy;
(1) all individual adaptive values in population are calculated, an array being made up of 150 adaptive values is obtained, is expressed as {Fitness1,Fitness2,…,Fitness150, wherein Fitnessindividual(1≤individual≤150) represent and plant I-th ndividual individual adaptive value in group, in initial population, all individual adaptive values are
(0.677226,0.68764263,0.68707186,0.6705194,0.6021689,…,
0.75742006,0.7020548,0.70719177,0.7126141,0.63313353,0.7255993)
If the meansigma methodss of Population adaptation value are represented with averageFitness,
I.e.
AverageFitness=103.31777662038803/150=0.6887851774692535;It is random to generate one Individual real number start (0 < start < averageFitness), its numerical value are 0.36970036874340495;Make index=1, Index represents individual numbering, makes Population adaptation value sum sum initial value be Fitness1, sum=Fitness1=0.677226;
(2) select is made to be the quantity for currently having been chosen by individuality;Calculate
Pointer=start+select × averageFitness, i.e.,
Pointer=0.36970036874340495+0 × 0.6887851774692535, pointer are evaluation population The measurement foundation of middle individual fitness size, result of calculation is 0.36970036874340495, due to sum>Pointer, so The 1st position numerical value 1 of now index being stored in array individuals, during expression have selected population, numbering is 1 Individuality;
(3) select=select+1, now
Pointer=0.36970036874340495+1 × 0.6887851774692535, result of calculation is 1.058485546212658, due to now sum preserve be select=0 when sum final numerical value 0.677226, to sum and Pointer is compared,
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 now index is stored in array The 2nd position in individuals;The aforesaid operations in (3) are repeated, as select=N, stops selection operation; For example: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),
The individuality that numbering is 8,25,29,30 is can be seen that from data above no selected in the selection process, table Bright these individual fitnesses are little, thus selected probability is less;Numbering be 22,28,55,122 individuality in the selection process It is selected repeatedly, show that these individual fitnesses are big, thus selected probability is big;
(4) numeral in individuals arrays is sequentially replaced as subscript with corresponding each individuality of these subscripts Each changed in current population is individual, obtains and former Population Size identical a new generation population;
Step 6:For any two individuality A in population1And A2If, It is false If the offspring individual produced after crossover operation is A1' and A2';The real number of one 0 to 1 is generated at random, and the random number for generating here is 0.53896, due to PcMore than this real number, therefore crossover operation is performed, the offspring individual produced after crossover operation replaces parent Individuality enters new population, and the individuality 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,2 1,8,24);
A2=(19,12,7,20,13,9,2,11,1,22,8,6,3,4,23,18,15,10,17,21,14,1 6,5,24);
Then A1And A2Different number of positions t=22 of numerical value, A in middle same position1And A2In middle same position, numerical value is identical Number of positions n-t=2;
(2) 150 sequences are produced, each sequence pair answers the arrangement that length is 22, and k-th sequence can in N number of sequence To be expressed asWherein
K=1,2 ..., 150,1≤u≤22;<ru×k>Expression takes ruThe fractional part of × k, if fractional part is negative Number, then negative plus 1, makes the negative become a positive number, wherein ru=2cos (2 π u/q), q is to meet q >=2t+3 most Little prime number, q >=2t+3=47 here, thus q takes 47, for example, works as u=3, and during k=1, r3× 1= 1.9289383501087531, then<r3×1>=0.9289383501087531;Work as u=4, during k=1,
r4× 1=-6.482505539488857,<r4×1>=-0.482505539488857, then will<r4×1> Numerical value be transformed into<r4×1>=-0.482505539488857+1, i.e., 0.5174944605111431;As k=2, pass through Calculated 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) delete A1And 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 individual position;By the different numerical value in remaining 22 same positions according to by Little to be ranked up to big order, the sequence being made up of 22 numerical value after note sequence is represented with s, s=<s1,s2,…,s22>, its Middle 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>;WillIt is arranged as according to ascending orderRemember the sequence For Pk', here by P2In all numerical value be ranked up according to ascending order, 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 sequencekLocation in ', according to the situation of change pair of position siIn s, location is readjusted, and is obtained by s1,s2,…,s22One new sequence of composition, is designated as s ', for example P2In the numerical value 0.9643 of the 1st position its position become for 22 through sequence, then the numerical value 1 on the 1st position in s is deposited It is placed on the 22nd position of the new sequence that length is 22, P2In the 2nd position numerical value 0.8579 through sequence its position be changed into 18, then the numerical value 2 on the 2nd position in s is stored in into the 18th position ... of the new sequence that length is 22, P2In The numerical value 0.0802 of 22 positions becomes for 2 its position through sequence, then be stored in the numerical value 23 on the 22nd position in s Length is the 2nd position of 22 new sequence, through which to P2In 22 numerical value location carries out weight in the sequence It is new adjust after obtain that (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 Obtain by s1,s2,…,stOne new sequence of composition, each numerical value reused in the sequence sequentially fill A1And A2In There are in same position 22 positions of different numerical value, just obtained a new sequence, be designated as S2, the 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 ..., during each numerical value in 149,150, aforesaid operations in (3) are carried out, it is possible to which generating 150 length is 24 sequence, is designated as
S={ S1,S2,…,S150};
(4) adaptive value of 150 sequences generated in calculating (3), A1' and A2Numerical value and adaptive value in ' on each position Numerical value correspondence in maximal sequence on each position is identical;Here the maximum adaptation value in calculated 150 sequences is 0.74999994, corresponding sequence for (9,12,4,19,8,15,5,6,24,10,13,17,21,1,11,18,7,22,16,3, 2,14,20,23), thus A1' and A2' is
(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:Perform mutation operation;
For in population, any one is individual, it is assumed that for B, the random real number for generating 0 to 1, work as PmMore than this reality During number, mutation operation is performed to B, the process of mutation operation is:Two positions are randomly choosed from B, by the two positions Numerical value is swapped, so as to obtain a new individual B ';For example, for certain the individual B in population,
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), The real number of random 0 to 1 for generating is 0.5114276945945321, meets 0.55 > 0.5114276945945321, holds Row variation is operated:From on B, randomly selected two positions are 7 and 11, the numerical value on the two positions is swapped and obtains one Individual 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:Maximum adaptation value and its corresponding individuality after record current iteration, the maximum adaptation after current iteration It is worth for 0.78224885, the corresponding individuality of the adaptive value is
(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 current iteration number of times more than maximum Iterationses MAX, MAX=50, if end condition is set up, then the priorities of test cases collating sequence for now obtaining is for most Excellent priorities of test cases collating sequence, exports the sequence and stops iteration;Otherwise, iterationses g=g+1, return to step are made Five, continue iteration.For example, after the 50th iteration, in population, maximum adaptation value is 0.79723173, the optimum test case of output Prioritization sequence is
(13,20,9,15,8,4,1,16,6,10,3,5,24,7,19,2,12,11,22,21,18,17,14,23)。
Can realize sorting for the priorities of test cases of white-box testing by above procedure, for jasmine programs Sentence coverage information, respectively the method in traditional genetic algorithm and the present invention is respectively performed 20 times.
During Fig. 2 is 20 experiments, the adaptive value meansigma methodss of 50 iteration are with iterationses 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 is compared traditional genetic algorithm and has faster convergence rate.
Fig. 3 is the casing figure of maximum adaptation value in 20 experiments of traditional genetic algorithm and this method, contrasts two auxiliary box body figures Understand, the data distribution that this method is obtained more is concentrated, i.e., carried out using this method it is preferential for the test case of white-box testing The stability that optimal sequencing result is generated during level sequence is more preferable.
Instance analysis shows that the priorities of test cases sort method for white-box testing proposed by the present invention 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, generates the good stability of optimum priorities of test cases collating sequence, is that one kind is 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 step:
Step one:For a program to be measured, tested using the test use cases for having designed, test case is treated The sentence coverage condition of ranging sequence is recorded, and obtains the sentence coverage information matrix A that test case treats ranging sequence;Assume certain Program to be measured has m bar sentences, is tested with n test case, if test use cases are represented with Φ, Φ={ T1,T2,…, Ti,…,Tn, wherein TiI-th test case that (1≤i≤n) is concentrated for test case, the sentence coverage information matrix A of construction Size be n × m, in program to be measured, the scope of statement number is that 1 to m, the scope of test case numbering is 1 to n, if i-th Test case covers j-th sentence in performing, 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 to represent One priorities of test cases collating sequence, priorities of test cases collating sequence are exactly by having that test case numbering is constituted Sequence sequence, i.e. each individuality are encoded as an orderly test case numbering string, and the length of coding is the number of test case n;
Step 3:Construction fitness function;For arbitrary individuality, TSjJ-th sentence in program to be measured can be covered for first SjThe order residing in the test case Perform sequence of test case, it is assumed that has performed capped in program to be measured after test The quantity of sentence be M, then order as M sentence correspondence M, institute's orderliness sum isIt is possible thereby to construct Fitness function APSC, APSC represent the average percent that sentence is covered,
A P S C = 1 - TS 1 + TS 2 + TS 3 + ... + TS M n M + 1 2 n ,
I.e.Wherein TSj(1≤j≤M) can be counted with sentence coverage information matrix A Calculate, for the sentence S being cappedj, in A, first test case for covering the sentence of lookup is in the test case sequence Residing order, then this order is exactly TSjNumerical value;
Step 4:Random initializtion population;Population scale is set as N, i.e., in population, includes individuality, if representing population with D, Then
D=<r11,r12,…,r1n>,<r21,r22,…,r2n>,…,<ri1,ri2,…,rin>,…,<rN1,rN2,…,rNn>, its In<ri1,ri2,…,rin>I-th represented in population is individual;Crossover probability P is setcWith mutation probability PmAnd greatest iteration time Number MAX;Iterationses g=1 is made, starts iteration;
Step 5:Perform stochastic sampling selection strategy;
(1) all individual adaptive values in population are calculated, an array being made up of N number of adaptive value is obtained, is expressed as {Fitness1,Fitness2,…,FitnessN, wherein
Fitnessindividual(1≤individual≤N) represents i-th ndividual individual adaptive value in population, if planting Group adaptive value meansigma methodss represented with averageFitness, then
A real number start (0 is generated at random < start < averageFitness);Make index=1, index represent individual numbering, make Population adaptation value sum sum initial value For Fitness1
(2) select is made to be the quantity for currently having been chosen by individuality;Calculate
Pointer=start+select × averageFitness, pointer are to weigh individual fitness size in population Foundation, if Fitnessindex< pointer, then proceeding as follows:A.index=index+1, sum=sum+ Fitnessindex;B. the operation in a is repeated, as sum >=pointer, the value of index individuals is stored in into The select+1 position in array, and operate in stopping b;
(3) select=select+1, repeats the operation in (2), as select=N, stops selection operation;
(4) numeral in individuals arrays is sequentially replaced with corresponding each individuality of these subscripts and is worked as subscript Each in front population is individual, obtains and former Population Size identical a new generation population;
Step 6:Perform crossover operation;For any two individuality A in population1And A2If, The offspring individual produced after assuming crossover operation is A1' and A2';The random real number for generating 0 to 1, works as PcMore than this real number When, crossover operation is performed, the offspring individual produced after crossover operation replaces parent individuality to enter new population, is not intersected Individuality is directly copied into new population;The detailed process of crossover operation is as follows:
(1) calculate A1And A2The different number of positions of numerical value in middle same position, it is assumed that for t, then A1And A2Number in middle same position Value identical number of positions is n-t;
(2) N number of sequence is produced, each sequence is the arrangement that a length is t, and k-th sequence can be expressed as in N number of sequenceWherein
P 1 k = < r 1 &times; k > , P 2 k = < r 2 &times; k > , ... , P u k = < r u &times; k > , ... , P t k = < r t &times; k > ,
K=1,2 ..., N, 1≤u≤t,<ru×k>Expression takes ruThe fractional part of × k, if fractional part is negative, then will Negative adds 1, makes the negative become a positive number, wherein ru=2cos (2 π u/q), q is the least prime for meeting q >=2t+3;
(3) delete A1And 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 order, the sequence being made up of t numerical value after note sequence is s, s=<s1,s2,…,st>, its Middle s1≤s2≤…≤st;WillIt is arranged as according to ascending order Remember that the sequence is Pk';RecordIn P after sequencekLocation in ', according to the situation of change pair of position siIn s, location is readjusted, and is obtained by s1,s2,…,stOne new sequence of composition, is designated as s ', then makes A is filled respectively with each numerical value in s '1And A2There is in middle same position t position of different numerical value, one has just been obtained New sequence, is designated as Sk, the sequence length is n;When k takes 1,2 ..., N-1, during each numerical value in N, is carried out in (3) State operation, it is possible to generate the sequence that N number of length is n, be designated as S={ S1,S2,…,SN};
(4) adaptive value of the N number of sequence generated in calculating (3), A1' and A2Numerical value in ' on each position and adaptive value maximum sequence Numerical value correspondence in row on each position is identical;
Step 7:Perform mutation operation;
For in population, any one is individual, it is assumed that for B, the random real number for generating 0 to 1, work as PmDuring more than this real number, Mutation operation is performed to B, the process of mutation operation is:Two positions are randomly choosed from B, the numerical value on the two positions is entered Row is exchanged, so as to obtain a new individual B ';
Step 8:Maximum adaptation value and its corresponding individuality after record current iteration;
Step 9:Judge stopping criterion for iteration, the stopping criterion for iteration in this method is that current iteration number of times is more than greatest iteration Number of times MAX, if end condition is set up, then now the individual corresponding priorities of test cases collating sequence of maximum adaptation value is Optimum priorities of test cases collating sequence, exports the sequence and stops iteration;Otherwise, iterationses g=g+1 is made, 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 true CN106528433A (en) 2017-03-22
CN106528433B 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)

Cited By (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
CN107844427A (en) * 2017-11-29 2018-03-27 郑州云海信息技术有限公司 A kind of Test Case Prioritization method perceived based on test resource
CN109271320A (en) * 2017-11-07 2019-01-25 西安邮电大学 A kind of upper multiple target priorities of test cases sort method
CN109783349A (en) * 2018-12-10 2019-05-21 江苏大学 A kind of priorities of test cases sort method and system based on dynamical feedback weight
US20190163617A1 (en) * 2017-11-29 2019-05-30 Toyota Jidosha Kabushiki Kaisha Software quality determination apparatus, software quality determination method, and software quality determination program
CN109871311A (en) * 2017-12-04 2019-06-11 北京京东尚科信息技术有限公司 A kind of method and apparatus for recommending test case
CN110059015A (en) * 2019-04-28 2019-07-26 西安邮电大学 Evolution of Population multiple target priorities of test cases sort method
CN110502447A (en) * 2019-08-30 2019-11-26 西安邮电大学 A kind of regression test case priority ordering method based on figure
CN113128556A (en) * 2021-03-10 2021-07-16 天津大学 Deep learning test case sequencing method based on mutation analysis
US11068379B2 (en) 2017-11-29 2021-07-20 Toyota Jidosha Kabushiki Kaisha Software quality determination apparatus, software quality determination method, and software quality determination program
CN113742206A (en) * 2020-05-27 2021-12-03 南京大学 Test case priority algorithm selection method based on project characteristics
CN114978974A (en) * 2022-05-20 2022-08-30 国网重庆市电力公司电力科学研究院 Wireless communication module testing method, device, equipment and storage medium
WO2023103574A1 (en) * 2021-12-10 2023-06-15 深圳前海微众银行股份有限公司 Unit test method and apparatus, electronic device, storage medium, and program

Citations (3)

* 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)
US20160162392A1 (en) * 2014-12-09 2016-06-09 Ziheng Hu Adaptive Framework Automatically Prioritizing Software Test Cases

Patent Citations (3)

* 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
US20160162392A1 (en) * 2014-12-09 2016-06-09 Ziheng Hu Adaptive Framework Automatically Prioritizing Software Test Cases

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
KRISTEN R. WALCOTT 等: ""Time-Aware Test Suite Prioritization"", 《ISSTA "06 PROCEEDINGS OF THE 2006 INTERNATIONAL SYMPOSIUM ON SOFTWARE TESTING AND ANALYSIS》 *
张卫祥 等: ""一种基于遗传算法的测试用例优先排序方法"", 《小型微型计算机系统》 *
程俊: ""多目标测试用例预优化方法及其在GPU上的应用研究"", 《万方数据知识服务平台》 *

Cited By (20)

* 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
CN109271320A (en) * 2017-11-07 2019-01-25 西安邮电大学 A kind of upper multiple target priorities of test cases sort method
CN109271320B (en) * 2017-11-07 2021-09-24 西安邮电大学 Higher-level multi-target test case priority ordering method
US10783067B2 (en) * 2017-11-29 2020-09-22 Toyota Jidosha Kabushiki Kaisha Software quality determination apparatus, software quality determination method, and software quality determination program
CN107844427A (en) * 2017-11-29 2018-03-27 郑州云海信息技术有限公司 A kind of Test Case Prioritization method perceived based on test resource
US20190163617A1 (en) * 2017-11-29 2019-05-30 Toyota Jidosha Kabushiki Kaisha Software quality determination apparatus, software quality determination method, and software quality determination program
US11068379B2 (en) 2017-11-29 2021-07-20 Toyota Jidosha Kabushiki Kaisha Software quality determination apparatus, software quality determination method, and software quality determination program
CN109871311A (en) * 2017-12-04 2019-06-11 北京京东尚科信息技术有限公司 A kind of method and apparatus for recommending test case
CN109783349A (en) * 2018-12-10 2019-05-21 江苏大学 A kind of priorities of test cases sort method and system based on dynamical feedback weight
CN109783349B (en) * 2018-12-10 2022-02-15 江苏大学 Test case priority ranking method and system based on dynamic feedback weight
CN110059015A (en) * 2019-04-28 2019-07-26 西安邮电大学 Evolution of Population multiple target priorities of test cases sort method
CN110059015B (en) * 2019-04-28 2022-09-30 西安邮电大学 Method for sequencing priorities of population evolution multi-target test cases
CN110502447A (en) * 2019-08-30 2019-11-26 西安邮电大学 A kind of regression test case priority ordering method based on figure
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
CN113128556A (en) * 2021-03-10 2021-07-16 天津大学 Deep learning test case sequencing method based on mutation analysis
CN113128556B (en) * 2021-03-10 2022-10-28 天津大学 Deep learning test case sequencing method based on mutation analysis
WO2023103574A1 (en) * 2021-12-10 2023-06-15 深圳前海微众银行股份有限公司 Unit test method and apparatus, electronic device, storage medium, and program
CN114978974A (en) * 2022-05-20 2022-08-30 国网重庆市电力公司电力科学研究院 Wireless communication module testing method, device, equipment and storage medium
CN114978974B (en) * 2022-05-20 2023-09-19 国网重庆市电力公司电力科学研究院 Wireless communication module testing method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN106528433B (en) 2018-10-02

Similar Documents

Publication Publication Date Title
CN106528433A (en) Testing case priority ranking method for white-box testing
CN104765690B (en) Embedded software test data generation method based on fuzzy genetic algorithm
CN108985335B (en) Integrated learning prediction method for irradiation swelling of nuclear reactor cladding material
CN102141958B (en) Method for evolving and generating path coverage test data facing defects
Khor et al. Using a genetic algorithm and formal concept analysis to generate branch coverage test data automatically
CN107368613A (en) Short text sentiment analysis method and device
CN106407258A (en) Missing data prediction method and apparatus
Kangas et al. Applying stochastic multicriteria acceptability analysis to forest ecosystem management with both cardinal and ordinal criteria
CN109448795A (en) The recognition methods of circRNA a kind of and device
CN110414580A (en) Reinforced concrete deep beam bearing capacity evaluation method based on random forests algorithm
CN104966106A (en) Biological age step-by-step predication method based on support vector machine
CN105631536A (en) Massive open online course (MOOC) quitting prediction algorithm based on semi-supervised learning
CN111784084A (en) Travel generation prediction method, system and device based on gradient lifting decision tree
Lisiński et al. Principles of the application of strategic planning methods
CN106156857A (en) The method and apparatus selected for mixed model
CN109358185A (en) Rubber compounding performance prediction model and prediction technique based on extreme learning machine
CN104572868B (en) The method and apparatus of information matches based on question answering system
CN109977030A (en) A kind of test method and equipment of depth random forest program
CN113762534B (en) Building cold and hot load prediction method, device, equipment and storage medium
CN115269572A (en) Subject item establishment decision recommendation method and device based on mass scientific research data
CN114091964A (en) Supplier multi-index evaluation method based on error inverse propagation algorithm
Roeva et al. Generalized net model of selection operator of genetic algorithms
Li et al. Parameters optimization of back propagation neural network based on memetic algorithm coupled with genetic algorithm
Han et al. The Analysis of Exam Paper Component based on genetic algorithm
Rawat et al. A comparative review between various selection techniques in genetic algorithm for finding optimal solutions

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