Summary of the invention
The technical matters that the present invention solves is: overcome the deficiencies in the prior art, provide a kind of by ant colony optimization algorithm and multi-core parallel concurrent calculating are combined, improve the parallel test case sequence generating method based on ant group algorithm of priorities of test cases sequence validity and rapidity.
Technical solution of the present invention is: a kind of parallel test case sequence generating method based on ant group algorithm, comprises the steps:
(1) use n ant from initially waiting to select to select test case test case list respectively based on ant group algorithm, what then upgrade ant respectively treats the list of selection test case, continue to select next test case and upgrade ant wait select test case list, repeat said process until the test case sequence length of n ant selection is n, obtain the test case sequence of the 1st iteration n ant, wherein n ant walks abreast and selects test case or upgrade it to wait to select test case list; Described initially waiting selects test case list to comprise test case Ti, i=1,2,3,, n; The test case tabulating method of described renewal ant is that the test case selected by this ant is from initially treating to reject the list of selection test case;
(2) obtain its seriousness numerical value after the seriousness of defect being divided, and be designated as S (l), then calculate test case Ti can find defect counts, test case Ti execution time obtain the defect detection efficiency Rf of test case Ti
i, and calculate the significance level IS of test case Ti in all test cases
i, wherein
L=1,2,3,, q, q are the number of defect, and max (Sf) is the maximal value of defect seriousness numerical value in test case, and r is the defects count that test case Ti can detect;
(3) pheromones on the path formed test case Ti and test case Td upgrades,
τ
id(t+1)=(1-ρ)·τ
id(t)+Δτ
id
If ant k have selected other situations of path between test case node Ti to test case node Td
Wherein, d=1,2,3,, n, t are iterations and initial value is 1, τ
id(1) dissipation rate of pheromones that to be 0.5, ρ be, τ
id(t+1) be from the Pheromone update amount the path test case node Ti to test case node Td in (t+1) secondary iterative process, τ
idt () is the pheromones on the path in the t time iterative process between Ti to Td, (1-ρ) τ
idt () is pheromones residual on the path in the t time iterative process between Ti to Td, Δ τ
idbe pheromones increment total on the path in the t time iterative process between Ti to Td,
be the pheromones in the t time iterative process, the path of ant k between Ti to Td stayed, Q is constant, represents the pheromones total amount that has of ant, h (k) be in the t time iterative process ant k in t iteration about the function of defect detection efficiency, M
kthe test case number selected when ant k detects all defect in the t time iterative process, Rf
i kt () is the defect detection efficiency Rf of the test case Ti that in the t time iterative process, ant k selects
i;
(4) n ant is used respectively respectively from initially waiting to select to select test case test case list, what upgrade ant respectively treats the list of selection test case, then respectively from its wait the test case selecting to select transition probability maximum test case list and upgrade ant wait select test case list, repeat said process until the test case sequence length of n ant selection is n, obtain the test case sequence of the t+1 time iteration n ant; Described transition probability is the probability jumping to another test case in current test case situation, and wherein, the transition probability that test case Ti jumps to test case Td is
Wherein, η
id(t)=IS
d(t), α, β are regulating parameter, and s is positive integer,
for ant k treating after selecting test case Ti selects test case list, n ant walks abreast and selects test case or upgrade it to wait to select test case list;
(5) t=t+1, and repeat step (3) to step (4) until the test case sequence of n ant that obtains of the test case sequence of n ant that obtains of a time iteration and the a-1 time iteration is identical, wherein a is not less than 2;
(6) the APFD value of the test case sequence of n the ant using APFD module calculating the 1st to a time iteration to obtain, and the test case sequence selecting APFD value maximum exports as optimized test case sequence.
In described step (1) from initially waiting to select to select test case test case list, the continuation in step (1) is continuous selects next test case or step (4) from initially waiting to select to select the method for test case to be Stochastic choice test case list.
The method obtaining its seriousness numerical value after dividing the seriousness of defect in described step (2) comprises the steps:
(1) according to the seriousness of defect in software, defect is divided into defect rank to be seen, light defects grade, general defect rank, major defect grade, major defect grade;
(2) quantification carried out to the severity level of each defect and obtain seriousness numerical value S (l) corresponding to each defect, wherein, the seriousness numerical value of defect rank to be seen is 2, the seriousness numerical value of light defects grade is 4, the seriousness numerical value of general defect rank is 6, the seriousness numerical value of major defect grade is 8, and the seriousness numerical value of major defect grade is 10.
The present invention's advantage is compared with prior art:
(1) seriousness of the defect that test case can find by the inventive method defects count, execution time of test case and test case find is as the parameter of pheromone updating rule and test case sensor selection problem rule, compared with prior art, important defect can be detected faster in regression test process;
(2) the inventive method compared with prior art, adds in the middle of generative process by ant group algorithm and intelligent optimization algorithm parallel characteristics, and the final cycle tests generated not only has good priority, and formation speed is fast;
(3) the inventive method compared with prior art, overcome prior art ignorance different software defect and different deficiencies is affected on software quality, realize simple in addition, convenient operation, be applicable to the prioritization of the large scale test use-case in regression test, improve validity and the rapidity of regression test process.
Embodiment
The present invention proposes a kind of parallel test case sequence generating method based on ant group algorithm in software regression testing process, calculated by ant colony optimization algorithm and multi-core parallel concurrent and combine, improve validity and the rapidity of priorities of test cases sequence, comprise the factor that (1) determines to affect priorities of test cases; (2) priority of ant colony optimization algorithm analytical test use-case; (3) the multi-core parallel concurrent process of ant colony optimization algorithm; (4) evaluation of priorities of test cases analysis result.Below in conjunction with example, the present invention will be further described:
Step one: determine the factor affecting priorities of test cases
(1) the defect detection efficiency of test case is calculated
In test process, the selection of test case and sequence are by the impact of many factors, for regression test, the major influence factors considered has three: the defects count that test case can find, the seriousness of the defect that the execution time of test case and test case find, the inventive method summation considers this three factors, wherein, the defects count that test case can find reflects the covering power that this test case detects software defect, a test case may find one or more software defect in the process of implementation, the software defect found is more, illustrate that the covering power of this test case to software defect is stronger, priority is higher, the execution time of test case reflects the testing efficiency of this test case, and in regression test, due to the time-constrain of test process, test use cases can not all perform usually, and the execution time of test case is shorter, and priority is higher, the seriousness of the defect that test case finds reflects the significance level that this test case detects defect, software is different to the acceptable degree of software defect in various degree, in order to the software defect that discovery early in test process is serious, the seriousness of the defect that test case finds is higher, and priority is higher.
Execution time two factors of the defects count that test case can find and test case can be carried out comprehensively, form the defect detection efficiency of test case, defect detection efficiency is the defects count found in the test case unit execution time, reflect the rapidity that test case detects defect, the defect detection efficiency circular of test case Ti is as follows:
(2) seriousness that test case detects defect is calculated
Conveniently the seriousness of analyzing defect is on the impact of priorities of test cases, in the present invention, the seriousness of defect is carried out quantification process, the defect of different brackets gives different numerical value (wherein, defect rank draws the criteria for classifying can select " QUALITY STANDARDS DEFECT MEASUREMENTMANUAL, United Kingdom Software Metrics Association October 2000 " middle method), as shown in the table:
The quantification of table 1 defect seriousness
Defect severity level |
Seriousness numerical value |
Defect to be seen (Level_1) |
2 |
Light defects (Level_2) |
4 |
General defect (Level_3) |
6 |
Major defect (Level_4) |
8 |
Major defect (Level_5) |
10 |
The defect that then test case Ti detects may comprise the defect of different menace level, and total defect seriousness numerical value is:
Wherein, S (l) represents the seriousness numerical value of defect l, and r is the defects count that test case Ti can detect.Detecting in defect seriousness, the significance level of test case Ti in all test cases may be calculated:
Wherein, max (Sf) is the maximal value of defect seriousness numerical value total in all test cases.
Step 2: the priority of ant colony optimization algorithm analytical test use-case
(1) the ant group algorithm modeling of priorities of test cases analysis
The inventive method utilizes ant group algorithm to solve priorities of test cases problem, first needs the Ants model building this problem.In Ants model, each ant builds a paths by search rule, a node on this paths represents a test case, therefore, a sequence of the corresponding test case of a fullpath of ant, n ant just constructs the n bar sequence of test case, the sequence that in this n bar sequence, existence one is optimum, the weight of optimal sequence (optimal path) is strengthened, repeat aforesaid operations, after successive ignition, the test case sequence of global optimum can be found.
Be illustrated in figure 2 ant group algorithm model schematic in the inventive method.In regression test, suppose to comprise n test case in initial test use cases T, in T, the initiation sequence of test case is { T1, T2, ..., Ti ..., Tn}, these test cases can detect m software defect altogether, and in Ants model, the number of ant is n.Ti represents i-th test case in test use cases T, test case list (being made up of remaining (n-j+1) individual test case node) to be selected after test case that Lj represents that ant have selected (j-1).At initial time, n ant is randomly placed in test case list L1, then the next test case node of each ant Stochastic choice in the test case list L2 that the next one is to be selected, by that analogy, until the test case that each ant is selected covers m software defect.After an iteration completes, an ant constructs a test case sequence, then said process is repeated according to pheromone updating rule and test case sensor selection problem rule, wherein, in T, the initiation sequence of test case is that n ant Stochastic choice obtains for n time, and first test case in test case sequence is Stochastic choice.
Ant is independent toward each other in structure test case sequence process, and this is the basis of carrying out multi-core parallel concurrent process.In addition, after ant often selects a test case node, the test case list Lj that treat selection carries out renewal rewards theory, and each ant has and independently waits to select test case list.
(2) pheromone updating rule
After an iteration completes, to upgrade by following rule the pheromones on every paths,
τ
id(t+1)=(1-ρ)·τ
id(t)+Δτ
id
If ant k have selected other situations of path between test case node Ti to test case node Td
Wherein, τ
id(1) dissipation rate of pheromones that to be 0.5, ρ be, span is [0,1], can get 0.6, τ
id(t+1) be from the Pheromone update amount the path test case node Ti to test case node Td in (t+1) secondary iterative process, τ
idt () is the pheromones on the path in last iterative process between Ti to Td, i.e. (1-ρ) τ
idt () is residual pheromones, Δ τ
idfor pheromones increment total on the path between Ti to Td,
for the pheromones that the path of ant k between Ti to Td stays, Q is a constant, represents the pheromones total amount that an ant has, and can get 100, h (k) is ant k function about defect detection efficiency in t iteration, M
kit is the test case nodes selected when ant k detects all defect in the t time iteration.Due to the ratio that defect detection efficiency is defects count and the execution time detected, therefore, consider the first two factor affecting priorities of test cases in function h (k), the value of function h (k) is larger, illustrates that the test case sequence that ant k builds is better.
(3) test case sensor selection problem rule
Test case sensor selection problem rule determines the probability selecting next test case, without loss of generality, suppose that ant k have selected test case node Ti in a jth test case list Lj to be selected, then at the next one, the probability of test case node Td namely in (j+1) individual test case list L (j+1) to be selected, is selected to provide by following rule:
η
id(t)=IS
d(t)
Wherein, η
idt () is heuristic function, indicate from test case node Ti to the expectation value selecting next test case node Td, η
idt the value of () is larger, illustrate that more test case Td is selected in expectation in the test case list L (j+1) that the next one is to be selected,
(j+1) for ant k individual test case list to be selected, test case sensor selection problem rule
pheromones τ on the path formed by test node
id(t) and heuristic function η
idt () determines jointly, α, β are regulating parameter, α=1, and β=2 can regulate τ
id(t) and η
idt () is right
influence degree.η
idthe seriousness degree of t software defect that the value of () is found by next test case Td and determining, therefore, η
idt () considers the 3rd factor affecting priorities of test cases.
Step 3: the multi-core parallel concurrent process of ant colony optimization algorithm
The Ants model that step 2 is set up is found in optimum test case sequence process, each ant independently builds oneself test case sequence, only all construct the test case sequence of oneself all ants after, just share the result built and lastest imformation element, namely there is the communication between ant.The process that therefore each ant can be built test case sequence is assigned to independently thread, isolated operation, and then shared by operation result, the advantage calculated by utilizing computing machine multi-core parallel concurrent is raised the efficiency.Each ant builds in the process of test case sequence, what elapsed time was maximum is loop iteration and circulation assignment, the inventive method utilizes Intel threading building module TBB (Thread Building Block) to carry out parallelization cycle for the treatment of iteration and circulation assignment, and the part of process comprises:
(1) initialized TBB stencil design
When problem initialization, n ant is placed at random in initial test case list L1, parallel_for parallel templates in TBB is utilized to write the template class of each ant of initialization, a constructed fuction and operator interface is comprised in this template class, initialization ant data structure in constructed fuction, realized the initialization of ant by the double circulation after optimization in operator interface, the test case sequence that in outer circulation, initialization ant builds is zero, the software defect number detected is zero, and make a test case in ant Stochastic choice L1, Inner eycle arranges the test case list to be selected of the next one of ant.
(2) each ant builds the TBB stencil design of test case sequence process
Parallel_reduce parallel templates in TBB is utilized to write the template class of each ant structure test case sequence process, two constructed fuctions are comprised in this template class, operator interface and join interface, a constructed fuction utilizes image parameter initialization ant data structure, another constructed fuction builds subtask, support the union operation in join interface, operator interface supports the parallel processing of task in loop body, realize ant in loop body and select next test case node, the renewal of test case list to be selected and the renewal of the test case sequence built and the software defect number detected, wherein ant selects the operation of next test case node to be calculate according to test case sensor selection problem rule, the result that each ant in multiple thread builds test case sequence merges by join interface, be convenient to sharing of each ant solving result.
(3) the TBB stencil design of the pheromones on refresh test case node path
The parallel_for parallel templates in TBB is utilized to write the template class of the pheromones on refresh test case node path, a constructed fuction and operator interface is comprised in this template class, constructed fuction is an empty realization, and operator interface calculates pheromones residual on any two test case node paths.The calculating of the pheromones on test case node path needs to follow pheromone updating rule, comprise the residual pheromones of last iteration and pheromones increment two parts, the calculating of pheromones incremental portion needs to carry out information sharing continually between each ant, parallel processing is not efficient, this part-serial process, and the calculating of residual pheromones is relatively independent, is adapted to parallelization, therefore, operator interface only calculates pheromones residual on two test case node paths.
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, weigh by inspection software defect efficiency here.APFD (Average of the percentage of faults detected) is as module.(list of references: 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 comprising n test case, m is the software defect quantity that test use cases T detects, a Test Case Prioritization of T is T ', TF
ifor first position of test case in Test Case Prioritization T ' of defect i being detected, then the APFD for Test Case Prioritization T ' is calculated as follows:
The span of APFD is 0% to 100%, the value of APFD is larger, illustrate that corresponding Test Case Prioritization method detects that the speed of software defect is faster, namely use APED module to calculate the APED value of the test case sequence of all n the ant that iteration obtains, and the test case sequence selecting APED value maximum export as optimized test case sequence.
Experimental verification is carried out to the technical method that the present invention proposes below, regression tested test case is concentrated and is comprised 8 test cases, the initial sequence of these 8 test cases is { T1, T2, T3, T4, T5, T6, T7, T8}, these test cases cover 10 software defect { F1 altogether, F2, F3, F4, F5, F6, F7, F8, F9, F10}, 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 can find, execution time can be calculated by historical data with the seriousness detecting defect, set forth in detail these parameters in table 2, these parameters are input parameters of multi-core parallel concurrent ant group algorithm.We compare the performance detecting defect that four kinds of test cases perform sequence, and these four kinds of test cases perform sequence and are respectively:
Initial sequence { T1 → T2 → T3 → T4 → T5 → T6 → T7 → T8};
Theoretical optimal sequencing is { T3 → T1 → T5 → T4 → T6 → T7 → T8 → T2};
ACO sequence { T1 → T3 → T5 → T7 → T6 → T2 → T4 → T8} of the present invention;
Randomly ordered { T7 → T5 → T4 → T6 → T1 → T3 → T8 → T2}.
In order to more different test case performs the performance detecting defect of sequence comprehensively, as shown in Fig. 3, Fig. 4, Fig. 5, the present invention compares from APFD, the number percent detecting number of defects, the seriousness detecting defect and these aspects of execution time, as shown in table 3, as can be seen from the table, the performance of ACO sequence and theoretical optimal sequencing is suitable, APFD is 82.5%, and just 10 software defects all can be detected as long as perform front 3 test cases, the execution time is 16 chronomeres; Secondly, APFD is 76.25% to the performance of initial sequence, and detecting whole defect needs to perform front 5 test cases, and the execution time is 24 chronomeres; Randomly ordered performance is the poorest, and APFD is 66.25%, and detecting whole defect needs to perform front 6 test cases, and the execution time is 29 chronomeres.Visible, test case execution sequence under theoretical optimal sequencing and ACO sort is beneficial to the detection of software defect most, this theoretical optimal sequencing is difficult to obtain in actual applications, therefore can obtain the test case execution sequence suitable with theoretical optimal sequencing performance with the present invention.
Table 2 test case, detect the relation of defect and execution time
The different test case of table 3 performs the performance detecting defect of sequence
According to above-mentioned four steps, the test case sequence generating method based on ant group algorithm walked abreast can be realized, the method has considered defect seriousness three aspects that defects count that test case finds, execution time of test case and test case find and has analyzed the priority that test case performs, optimum test case can be gone out perform sequence by rapid solving, make regression test within the shortest time, detect the defect of software, improve validity and the rapidity of regression test process, the regression test for software provides a kind of practical approach efficiently
The content be not described in detail in instructions of the present invention belongs to the known technology of those skilled in the art.