The content of the invention
Present invention solves the technical problem that being:Overcome the deficiencies in the prior art there is provided one kind by the way that ant group optimization is calculated
Method and multi-core parallel concurrent are calculated and are combined, and improve the parallel based on ant colony of priorities of test cases sequence validity and rapidity
The test case sequence generating method of algorithm.
The present invention technical solution be:A kind of parallel test case sequence generating method based on ant group algorithm,
Comprise the following steps:
(1) test case is selected from initial test case list to be selected using n ant based on ant group algorithm respectively,
Then test case list select of ant is updated respectively, and that continues to select next test case and update ant treats selection survey
Example list on probation, repeats said process up to the test case sequence length of n ant selection is n, obtains the 1st iteration n
The test case sequence of ant, wherein n ant selects test case or updates its test case list to be selected parallel;Institute
Stating initial test case list select includes test case Ti, i=1,2, and 3,, n;The test case row for updating ant
Table method is that the test case for selecting the ant is rejected from initial test case list to be selected;
(2) its seriousness numerical value is obtained after being divided to the seriousness of defect, and is designated as S (l), test is then calculated and uses
The defect counts that can be found that of example Ti, test case Ti execution time obtain test case Ti defect detection efficiency Rfi, and
Calculate significance level ISs of the test case Ti in all test casesi, wherein
L=1,2,3,, q, q is the number of defect, and max (Sf) is the maximum of defect seriousness numerical value in test case,
R is the defects count that test case Ti can be detected;
(3) pheromones on the path constituted to test case Ti with test case Td are updated,
τid(t+1)=(1- ρ) τid(t)+Δτid
Wherein, d=1,2,3,, n, t is iterations and initial value is 1, τid(1) it is that the dissipation that 0.5, ρ is pheromones is fast
Rate, τid(t+1) be in (t+1) secondary iterative process from the path test case node Ti to test case node Td
Pheromone update amount, τid(t) it is the pheromones on the path between Ti to Td in the t times iterative process, (1- ρ) τid(t) it is
The pheromones remained on path in the t times iterative process between Ti to Td, Δ τidFor between Ti to Td in the t times iterative process
Path on total pheromones increment,For the letter that ant k leaves on the path between Ti to Td in the t times iterative process
Breath element, Q is constant, represents the pheromones total amount that possesses of ant, and h (k) is that ant k is closed in t iteration in the t times iterative process
In the function of defect detection efficiency, MkThe test case number selected when being ant k detections all defect in the t times iterative process,For the test case Ti selected of ant k in the t times iterative process defect detection efficiency Rfi;
(4) test case is selected from initial test case list to be selected respectively using n ant respectively, updated respectively
The test case list to be selected of ant, then selects the maximum survey of transition probability from its test case list to be selected respectively
Example on probation and the test case list to be selected for updating ant, repeat said process until the test case sequence of n ant selection
Row length is n, obtains the test case sequence of n ant of the t+1 times iteration;The transition probability is current test case feelings
The probability of another test case is jumped under condition, wherein, the transition probability that test case Ti jumps to test case Td is
Wherein, ηid(t)=ISd(t), α, β are regulation parameter, and s is positive integer,It is that ant k is selecting test case
Test case list to be selected after Ti, n ant selects test case or updates its test case list to be selected parallel;
(5) t=t+1, and repeat step (3) is to step (4) until the test case for the n ant that a times iteration is obtained
Sequence is identical with the test case sequence for the n ant that the a-1 times iteration is obtained, and wherein a is not less than 2;
(6) APFD of the test case sequence for the n ant that the 1 to a times iteration is obtained is calculated using APFD modules
Value, and select the maximum test case sequence of APFD values to be exported as the test case sequence of optimization.
In described step (1) selected from initial test case list to be selected in test case, step (1) after
It is continuous continuous select next test case or step (4) selected from initially test case list select the method for test case for
Machine is selected.
Obtained after being divided in described step (2) to the seriousness of defect the method for its seriousness numerical value include it is as follows
Step:
(1) defect is divided into by defect rank to be seen according to the seriousness of defect in software, it is light defects grade, general
Defect rank, major defect grade, major defect grade;
(2) quantification is carried out to the severity level of each defect and obtains the corresponding seriousness numerical value S of each defect
(l), wherein, the seriousness numerical value of defect rank to be seen is 2, and the seriousness numerical value of light defects grade is 4, general defect etc.
The seriousness numerical value of level is 6, and the seriousness numerical value of major defect grade is 8, and the seriousness numerical value of major defect grade is 10.
The advantage of the present invention compared with prior art is:
(1) defects count, the execution time of test case and the test that test case is can be found that by the inventive method are used
The seriousness for the defect that example is found selects the parameter of rule as pheromone updating rule and test case node, with prior art
Compare, important defect can be detected faster in regression test process;
(2) the inventive method compared with prior art, ant group algorithm and intelligent optimization algorithm parallel characteristics is added and generated
Among process, the cycle tests ultimately generated not only has preferable priority, and formation speed is fast;
(3) the inventive method compared with prior art, overcomes prior art and ignores different software defect to software quality
The different deficiency of influence, is realized simply in addition, is easy to operation, it is adaptable to the priority of the large scale test use-case in regression test
Sequence, improves the validity and rapidity of regression test process.
Embodiment
The present invention proposes a kind of parallel life of the test case sequence based on ant group algorithm during software regression testing
Into method, calculated and be combined by ant colony optimization algorithm and multi-core parallel concurrent, improve the validity of priorities of test cases sequence
And rapidity, include the factor of (1) determination influence priorities of test cases;(2) ant colony optimization algorithm analysis test case is excellent
First level;(3) the multi-core parallel concurrent processing of ant colony optimization algorithm;(4) evaluation of priorities of test cases analysis result.With reference to reality
The present invention will be further described for example:
Step one:It is determined that the factor of influence priorities of test cases
(1) the defect detection efficiency of test case is calculated
The selection and sequence of test case are influenceed by many factors in test process, for regression test, it is considered to
Major influence factors have three:Defects count, the execution time of test case and test case that test case is can be found that
It was found that defect seriousness, the inventive method considers three factors, wherein, the number of defects that test case is can be found that
Amount reflects the covering power that the test case is detected to software defect, and a test case may be found that one in the process of implementation
Individual or multiple software defects, the software defect of discovery is more, illustrates that the test case is stronger to the covering power of software defect, excellent
First level is higher;The execution time of test case reflects the testing efficiency of the test case, in regression test, due to testing
The time-constrain of journey, test use cases generally can not be performed all, and the execution time of test case is shorter, and priority is higher;Survey
The seriousness for the defect that example on probation is found reflects the significance level that the test case detects defect, and software is to different degrees of
The acceptable degree of software defect is different, for the serious software defect of the discovery in test process early, test case hair
The seriousness of existing defect is higher, and priority is higher.
Two factors of defects count and the execution time of test case that test case is can be found that can be integrated, shape
Into the defect detection efficiency of test case, defect detection efficiency is that test case unit performs the defects count found in the time,
The rapidity that test case detects defect is reflected, test case Ti defect detection efficiency circular is as follows:
(2) seriousness that test case detects defect is calculated
By the seriousness of defect in influence of the seriousness of analyzing defect to priorities of test cases for convenience, the present invention
Quantification processing is carried out, different grades of defect assigns different numerical value, and (wherein, defect rank is drawn the criteria for classifying and can selected
《QUALITY STANDARDS DEFECT MEASUREMENT MANUAL,United Kingdom Software Metrics
Association October 2000》Middle method), it is as shown in the table:
The quantification of the defect seriousness of table 1
Defect severity level |
Seriousness numerical value |
Defect (Level_1) to be seen |
2 |
Light defects (Level_2) |
4 |
General defect (Level_3) |
6 |
Major defect (Level_4) |
8 |
Major defect (Level_5) |
10 |
Then the defect of test case Ti detections may include the defect of different menace levels, total defect seriousness numerical value
For:
Wherein, S (l) represents defect l seriousness numerical value, and r is the defects count that test case Ti can be detected.In detection
In terms of defect seriousness, significance levels of the test case Ti in all test cases may be calculated:
Wherein, max (Sf) is the maximum of total defect seriousness numerical value in all test cases.
Step 2:Ant colony optimization algorithm analyzes the priority of test case
(1) the ant group algorithm modeling of priorities of test cases analysis
The inventive method solves the problems, such as priorities of test cases using ant group algorithm, it is necessary first to build the ant colony of the problem
Model.Each ant builds a node on a paths, this paths by search rule and represents one in Ants model
Test case, therefore, a sequence of the fullpath correspondence test case of ant, n ant just construct test and used
There is an optimal sequence in the n bar sequences of example, this n bar sequence, the weight to optimal sequence (optimal path) is strengthened,
Aforesaid operations are repeated, after successive ignition, you can find the test case sequence of global optimum.
It is illustrated in figure 2 ant group algorithm model schematic in the inventive method.In regression test, it is assumed that initial test
Comprising n test case in set of uses case T, the initiation sequence of test case is { T1, T2 ..., Ti ..., Tn } in T, these tests
Use-case can detect m software defect altogether, in Ants model, and the number of ant is n.Ti represents test use cases T
In i-th of test case, Lj represents that ant have selected the test case list that selection is treated after (j-1) test case (by residue
(n-j+1) individual test case node composition).In initial time, n ant is randomly placed in test case list L1,
Then each ant randomly chooses next test case node in next test case list L2 for treating selection, with such
Push away, until the test case that each ant selects covers m software defect.After the completion of an iteration, an ant builds
One test case sequence, then repeats said process according to pheromone updating rule and test case node selection rule,
Wherein, the initiation sequence of test case is obtained for n times for the random selection of n ants in T, and first in test case sequence test is used
Example is random selection.
Ant is independent toward each other in test case sequence process is built, and this is the basis for carrying out multi-core parallel concurrent processing.
In addition, ant is often selected after a test case node, the test case list Lj that treat selection is updated operation, and
Each ant possesses independent test case list to be selected.
(2) pheromone updating rule
After the completion of an iteration, the pheromones on every paths are updated by following rules,
τid(t+1)=(1- ρ) τid(t)+Δτid
Wherein, τid(1) it is dissipation rate that 0.5, ρ is pheromones, span is [0,1], can take 0.6, τid(t+
1) be in (t+1) secondary iterative process from the pheromones on the path test case node Ti to test case node Td more
New amount, τid(t) it is the pheromones on the path between Ti to Td in last iterative process, i.e. (1- ρ) τid(t) it is residual
Pheromones, Δ τitFor pheromones increment total on the path between Ti to Td,For paths of the ant k between Ti to Td
On the pheromones that leave, Q is a constant, represents the pheromones total amount that an ant possesses, it is ant k that can take 100, h (k)
Function in t iteration on defect detection efficiency, MkIt is to be selected in the t times iteration when ant k detects all defect
Test case nodes.Because defect detection efficiency is the ratio between defects count and execution time of detection, therefore, function h (k)
In consider the first two factor of influence priorities of test cases, function h (k) value is bigger, illustrate the test use that ant k is built
Example sequence is better.
(3) test case node selection rule
Test case node selection rule determines the probability for selecting next test case, without loss of generality, it is assumed that ant
Ant k have selected test case node Ti in the test case list Lj for treating selection j-th, then next, i.e., (j+1) is individual
Treat that the probability of selection test case node Td in the test case list L (j+1) of selection is provided by following rules:
ηid(t)=ISd(t)
Wherein, ηid(t) it is heuristic function, indicates from test case node Ti to the next test case node Td of selection
Desired value, ηid(t) value is bigger, illustrates more to expect selection test in next test case list L (j+1) for treating selection
Use-case Td,For ant k (j+1) individual test case list for treating selection, test case node selection rule
Pheromones τ on the path that test node is formedid(t) with heuristic function ηid(t) together decide on, α, β is regulation parameter, α=
1, β=2, τ can be adjustedidAnd η (t)id(t) it is rightInfluence degree.ηid(t) value is found by next test case Td
Software defect seriousness degree and determine, therefore, ηid(t) the 3rd factor of influence priorities of test cases is considered.
Step 3:The multi-core parallel concurrent processing of ant colony optimization algorithm
The Ants model that step 2 is set up is found in optimal test case sequence process, and each ant independently builds oneself
Test case sequence, only after the test case sequence that all ants all construct oneself, just share build result and
, that is, there is the communication between ant in fresh information element.Therefore the process that each ant can be built into test case sequence is assigned to
Then independent thread, isolated operation is shared operation result, and the advantage calculated by using computer multi-core parallel concurrent is come
Improve efficiency.During each ant builds test case sequence, elapsed time at most be loop iteration and circulation assignment,
The inventive method carries out parallelization processing cycle using Intel threading building modules TBB (Thread Building Block) and changed
Generation and circulation assignment, the part of processing includes:
(1) the TBB stencil designs of initialization
When problem is initialized, n ant is randomly placed in initial test case list L1, using in TBB
Parallel_for parallel templates write the template class for initializing each ant, in the template class comprising a constructed fuction and
Operator interfaces, initialize ant data structure, by dual after optimization in operator interfaces in constructed fuction
The initialization of ant is realized in circulation, and the test case sequence that ant structure is initialized in outer circulation is zero, and the software detected lacks
Sunken number is zero, and ant is randomly choosed a test case in L1, and interior circulation sets next survey for treating selection of ant
Example list on probation.
(2) each ant builds the TBB stencil designs of test case sequence process
The mould that each ant builds test case sequence process is write using parallel_reduce parallel templates in TBB
Comprising two constructed fuctions, operator interfaces and join interfaces in plate class, the template class, a constructed fuction is joined using object
Number initialization ant data structure, another constructed fuction builds subtask, supports the union operation in join interfaces,
Operator interfaces support the parallel processing of task in loop body, realize that ant selects next test case section in loop body
Point, treat selection test case list renewal and the test case sequence and the software defect number of detection that have built more
Newly, wherein ant selects the operation of next test case node to be to select rule to be obtained to calculate according to test case node,
Join interfaces merge the result that each ant in multiple threads builds test case sequence, are easy to each ant to solve
As a result shared.
(3) the TBB stencil designs of the pheromones on test case node path are updated
The mould for updating the pheromones on test case node path is write using the parallel_for parallel templates in TBB
A constructed fuction and operator interfaces are included in plate class, the template class, constructed fuction is that an empty real shows, and operator connects
Mouth calculates the pheromones remained on any two test case node path.The calculating of pheromones on test case node path
Need to follow pheromone updating rule, include the pheromones and pheromones increment two parts of last iteration residual, pheromones increase
The calculating of amount part needs continually to carry out information sharing between each ant, and parallel processing is not efficient, at the part-serial
Reason, and the calculating of the pheromones remained is relatively independent, is adapted to parallelization, therefore, operator interfaces only calculate two tests
The pheromones remained on case node path.
Step 4:The evaluation of priorities of test cases analysis result
(1) metric analysis of software defect detector efficiency.
In order to evaluate the effect that the inventive method is analyzed priorities of test cases, here with inspection software defect efficiency come
Weigh.APFD (Average of the percentage of faults detected) is used as module.(with reference to text
Offer:Rothermel G,Untch R H,Chu C,et al.Test case prioritization:An empirical
study[C]//Software Maintenance,1999.(ICSM’99)Proceedings.IEEE International
Conference on.IEEE,1999:179-188.)
If T is the set for including n test case, m is the software defect quantity that test use cases T is detected, the one of T
Individual Test Case Prioritization is T ', TFiTo detect position of defect i first test case in Test Case Prioritization T ',
Then it is calculated as follows for Test Case Prioritization T ' APFD:
APFD span is bigger for 0% to 100%, APFD value, illustrates the method detection of correspondence Test Case Prioritization
Speed to software defect is faster, i.e., the test case for the n all ants that iteration is obtained is calculated using APFD modules
The APFD values of sequence, and select the maximum test case sequence of APFD values to be exported as the test case sequence of optimization.
Experimental verification is carried out to technical method proposed by the present invention below, the test case of regression test, which is concentrated, includes 8
Individual test case, the initial of this 8 test cases is ordered as { T1, T2, T3, T4, T5, T6, T7, T8 }, and these test cases are total
10 software defects { F1, F2, F3, F4, F5, F6, F7, F8, F9, F10 } are covered altogether, and the seriousness numerical value of 10 defects is respectively
{ 4,2,2,8,10,8,10,4,6,6 }, the defects count that each test case is can be found that performs the time and detects the tight of defect
Principal characteristic can be calculated by historical data and obtained, and these parameters are set forth in detail in table 2, and these parameters are that multi-core parallel concurrent ant colony is calculated
The input parameter of method.We compare the performance that four kinds of test cases perform the detection defect of sequence, and these four test cases are held
Row sequence is respectively:
Initial sequence { T1 → T2 → T3 → T4 → T5 → T6 → T7 → T8 };
Theoretical optimal sequencing is { T3 → T1 → T5 → T4 → T6 → T7 → T8 → T2 };
ACO of the present invention sorts { T1 → T3 → T5 → T7 → T6 → T2 → T4 → T8 };
Randomly ordered { T7 → T5 → T4 → T6 → T1 → T3 → T8 → T2 }.
In order to compare the performance that different test cases perform the detection defect of sequence comprehensively, as shown in Fig. 3, Fig. 4, Fig. 5 originally
Invention is from APFD, the percentage that detects number of defects, the seriousness for detecting defect and execution time are compared in terms of these, such as
Shown in table 3, as can be seen from the table, quite, APFD is 82.5% to the performance of ACO sequences and theoretical optimal sequencing, as long as holding
Preceding 3 test cases of row just can all detect 10 software defects, and the time that performs is 16 chronomeres;Initially sort
Secondly, APFD is 76.25% to performance, and the whole defects of detection need to perform preceding 5 test cases, and the time that performs is 24 time lists
Position;Randomly ordered performance is worst, and APFD is 66.25%, and the whole defects of detection need to perform preceding 6 test cases, during execution
Between for 29 chronomeres.It can be seen that, the test case execution sequence under theoretical optimal sequencing and ACO sequence is most useful for software defect
Detection, the theoretical optimal sequencing is difficult to obtain in actual applications, therefore can obtain optimal with theory with the present invention
The suitable test case execution sequence of the performance that sorts.
The test case of table 2, detection defect and the relation for performing the time
The different test cases of table 3 perform the performance of the detection defect of sequence
, should according to aforementioned four step, you can realize the parallel test case sequence generating method based on ant group algorithm
The defect that defects count, the execution time of test case and the test case that method has considered test case discovery are found is tight
The priority that three aspects of principal characteristic are performed to test case is analyzed, and optimal test case can be gone out with rapid solving and performs row
Sequence so that regression test detects the defect of software within the shortest time, improves the validity of regression test process and quick
Property, provide a kind of efficient practical approach for the regression test of software
The content not being described in detail in description of the invention belongs to the known technology of those skilled in the art.