CN110109822A - The regression testing method of priorities of test cases sequence is carried out based on ant group algorithm - Google Patents

The regression testing method of priorities of test cases sequence is carried out based on ant group algorithm Download PDF

Info

Publication number
CN110109822A
CN110109822A CN201910254057.7A CN201910254057A CN110109822A CN 110109822 A CN110109822 A CN 110109822A CN 201910254057 A CN201910254057 A CN 201910254057A CN 110109822 A CN110109822 A CN 110109822A
Authority
CN
China
Prior art keywords
test
solution
node
sentence
ant
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
CN201910254057.7A
Other languages
Chinese (zh)
Other versions
CN110109822B (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.)
South China University of Technology SCUT
Original Assignee
South China University of Technology SCUT
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 South China University of Technology SCUT filed Critical South China University of Technology SCUT
Priority to CN201910254057.7A priority Critical patent/CN110109822B/en
Publication of CN110109822A publication Critical patent/CN110109822A/en
Application granted granted Critical
Publication of CN110109822B publication Critical patent/CN110109822B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/004Artificial life, i.e. computing arrangements simulating life
    • G06N3/006Artificial life, i.e. computing arrangements simulating life based on simulated virtual individual or collective life forms, e.g. social simulations or particle swarm optimisation [PSO]

Abstract

The invention discloses a kind of regression testing methods for carrying out priorities of test cases sequence based on ant group algorithm to calculate comprising steps of the test suite of tested program is converted into figure G by (1) and instantiate all human oasis exploiteds;(2) human oasis exploited starts to travel round figure G with the solution of construction problem, and before the transfer of ant state each time, human oasis exploited calculates the heuristic information of all both candidate nodes, and picks out next destination node that will be shifted;(3) after all human oasis exploiteds all complete the work of construction solution, rule is updated for the information cellulose content to update all sides in figure G by global information element;(4) test suite after being sorted when reaching termination condition, otherwise return step (2);(5) regression test successively is carried out to software using the test suite after sequence as test case.The present invention searches for optimal test case with ant group algorithm and executes sequence, to maximize the covering rate of sentence in tested program, improves the efficiency of regression test.

Description

The regression testing method of priorities of test cases sequence is carried out based on ant group algorithm
Technical field
The present invention relates to software tests and the big field of intelligence computation two, relate generally to one kind and are tested based on ant group algorithm The regression testing method of use-case priority ranking.
Background technique
Regression test is the special method for testing software of one of field of software engineering.The test refers to whenever programmer After modifying software source code, test is re-started all to ensure originally to have finished writing and the code well operated does not introduce new journey Sequence mistake, while newly added code can be executed correctly in this modification.Regression test as software life-cycle one A component part, through each stage of software development, the publication of each new version of software is required in advance by multiple The inspection of regression test, to ensure the correctness of software new function and original function.
The cost of regression test is often very high.This is because in regression test each time, software engineer New test case will be added for fresh code, while the correctness to ensure code early period, all test cases all can be by It saves, to be reused in following regression test.Which results in software test pond and test suite scales not Disconnected expansion.
Selection is suitable, correctly the tactful expense for reducing regression test is necessary, and one of technology is that test is used Example prioritization techniques.The time that the technology is tested by the test case execution sequence in optimal inspection set with optimized regression It arranges.Specifically, regression test priority ranking evaluates priority to each test case according to certain standard, further in accordance with This priority is that all test cases make descending sort.In this way, which the high test case of priority will be held earlier Row, the test target of regression test will also be met earlier.Since the test result and test that have been obtained earlier on important are anti- Feedback, programmer are able to carry out subsequent debugging and development earlier.In addition, if regression test activity surprisingly terminates, Test Case Prioritization prioritization techniques can guarantee that the partial test carried out before this possesses top gain.
Regression test has many possible test targets, most important one target first is that overlay program as early as possible In all sentences (executable lines of codes), that is, maximize test use cases sentence covering rate.It is main at present for the target Technology be divided into two class of Deterministic Methods and stochastic search methods.Deterministic Methods using the technology based on Greedy strategy as representative, Its main feature is that algorithm flow is simple, complexity is low;Random search algorithm mainly has genetic algorithm, ant group algorithm, particle swarm algorithm Deng feature is to possess stronger ability of searching optimum;Substantially due to the priorities of test cases sequencing problem based on coverage rate It is a np hard problem, Greedy strategy is only able to find locally optimal solution, and can not find globally optimal solution or approximate optimal solution;And Random search algorithm then has certain ability for jumping out locally optimal solution.
Ant group algorithm is a kind of powerful Evolutionary Computation.The algorithm was proposed by Dorigo in 1992 earliest.It delivers So far many combinatorial optimization problems have been successfully applied to;The advantages of ant group algorithm be can be scanned for using domain knowledge, thus It is quickly found out the solution of high quality.In the design of ant group algorithm frame, two crucial problems are how to design one effectively Heuristic function and a suitable pheromone update strategy;The relevant local message indirect labor ant of the former Utilizing question is searched Rope, the latter utilize historical search experience indirect labor's Ant Search of ant colony.However, existing be based on ant group algorithm and coverage rate Priorities of test cases ordering techniques be only conceived to the pheromone update strategy of deft design, but ignore and define one and meet The importance of the heuristic function of problem.This makes these methods not efficient enough when solving the above problems.In view of the above-mentioned problems, The invention proposes a kind of ACS algorithm frame based on additional coverage, while having invented a kind of completely new local search side Method is with the search of further indirect labor's ant colony.The present invention, which can be found, preferably maximizes sentence covering rate solution, further mentions The high efficiency of priorities of test cases ordering techniques.
Summary of the invention
In view of the above-mentioned problems, the invention proposes a kind of recurrence for carrying out priorities of test cases sequence based on ant group algorithm Test method.The present invention, which can be found, preferably maximizes sentence covering rate solution, and it is preferential to further improve regression test case The efficiency of grade ordering techniques, solves the problems, such as the time overhead in the regression test of field of software engineering, improves software test Movable efficiency.
ACS algorithm is used in the priorities of test cases sorting consistence problem based on covering herein, is improved back The efficiency for returning test, solves the technical issues of optimizing to Test Strategy.The ACS algorithm, which uses, to be based on additionally covering The heuristic rule of lid and local search approach based on sequence.
The present invention adopts the following technical scheme that realization:
A kind of regression testing method carrying out priorities of test cases sequence based on ant group algorithm, comprising steps of
(1) test suite comprising n test case, the corresponding tested program comprising m sentence is converted into figure G, Calculate first history optimal solutionAnd using its fitness as the pheromones initial concentration τ of figure G0, instantiate all artificial Ant;
(2) human oasis exploited starts to travel round figure G with the solution of construction problem, before the transfer of ant state each time, artificial ant Ant calculates the heuristic information of all both candidate nodes, and picks out next target that will be shifted according to pseudorandom ratio rules Node;After completing primary transfer, local information element, which updates rule, will act on the side shifted to reduce its pheromones Content;Later, ant judges whether to cover all sentences, if it is not, then continuing to shift;If so, stopping traveling round, step is gone to (3);
(3) after all human oasis exploiteds all complete the work of construction solution, the local search approach based on sequence is applied to Finely tune the solution of all generations;After this, the fitness of all solutions will be calculated, and therefrom select iteration optimal solution to history Optimal solution compares, and updates global optimum's path tree;It will be to update institute in figure G finally, updating rule by global information element There is the information cellulose content on side;
(4) it is terminated if algorithm reaches termination condition, the test suite after being sorted, otherwise return step (2);
(5) detection of regression test is successively carried out to software using the test suite after sequence as test case, it is ensured that software The correctness of new function and original function.
Further, in step (1), it is described one comprising n test case, it is corresponding include m sentence by ranging The test suite of sequence is converted into figure G and specifically includes:
One test suite comprising n test case, the corresponding tested program comprising m sentence will be converted into figure G ={ V, E }, wherein V={ v-1, v1, v2..., vnBe figure G node collection, it includes n physical node v1, v2..., vn, respectively Corresponding n test case and a dummy node v-1As the search starting point of all human oasis exploiteds, E={ Ev, ErIt is figure G Side collection, wherein Ev={ e (- 1,1), e (- 1,2) ..., e (- 1, n) } includes all sides that physical node is directed toward from dummy node, ErPacket Containing the real side between all physical nodes;Scheme each physical node v in Gi(i=1 2 ..., n) has its corresponding covering statement listJ is viTotal covering sentence number, sik, (1≤k≤j) is viCovering Line number of the kth sentence in tested program.
Further, in step (1), first history optimal solution of the calculatingAnd using its fitness as figure G's Pheromones initial concentration τ0, it instantiates all human oasis exploiteds and specifically includes:
1) its additional sentence is calculated to all test cases for being not belonging to construction solution and covers number;
2) use-case is randomly choosed from all additional test cases of the sentence covering number greater than 0, construction solution is added End;
3) total covering sentence number of construction solution is calculated, if being less than the total sentence number of tested program, return step 1), otherwise tie Beam calculates, and obtains first history optimal solution
4) according to a history optimal solutionCalculate the pheromones initial concentration of G
Further, in step (2), when the human oasis exploited calculates the heuristic information of all both candidate nodes,
The covering sentence collection of its own is arranged in each human oasis exploited kTo record it during traveling round The tested program sentence of covering is not completely cured and is updated according to the new test case being added in construction solution to it, update mode It is as follows:
Wherein,Indicate the new test case v being added into construction solutions, calculate beWithDifference set;
Itself covering sentence collection based on human oasis exploitedThe heuristic function of additional sentence covering calculates as follows:
Wherein, S is all sentence collection of tested program, | | | | calculate the element number in input set, ηk(s) it is used for That measure is the cost that ant k is transferred to node s, ηk(s) size determines whether ant k is worth being transferred to node;
According to above-mentioned heuristic rule, the cost metric (i.e. distance) for scheming any a line e (r, s) in G can pass through following formula It calculates:
Wherein, the distance δ of side e (r, s)k(r, s) is not a fixed value, but according to the difference of creeped ant And it is different.
Further, described to pick out next target section that shifted according to pseudorandom ratio rules in step (2) Point is defined as follows:
Wherein, r is the node that ant is currently located, and τ (r, t) is the information cellulose content on the path of node r to t, and β is one The parameter of the relative importance of a control pheromones and heuristic information;Q is an equally distributed random number, and value range is [0,1], q0It is a parameter on 0 to 1, plays threshold function;When q is less than or equal to q0When, s, which is equal to, obtains maximum [τ (r, t)] [ηk(t)]βThat node of value, otherwise s is equal to a random number S, and the random number S is by probability distribution in following formula The random number of generation:
It is J in formulak(r) set for all non-accessed nodes being connected with r is indicated.Possess biggish information cellulose content with The node of the β power product of heuristic information will have bigger probability to be selected.
Further, in step (2), the local information element updates rule by when ant shifts each time It waits, the information cellulose content in that corresponding a line is shifted in evaporation, avoids subsequent ant and follows identical track of creeping, reaches Diverging search avoids the purpose for falling into locally optimal solution, and the local information element updates rule and is defined as follows:
τ (r, s) ← (1- ρ) τ (r, s)+ρ τ0
Wherein, [0,1] ρ ∈ is the parameter for controlling pheromones rate of decay, τ0It is the pheromones initial concentration of figure G.
Further, in step (3), the global information element updates rule and passes through the information on all sides in evaporation figure G Element, while in the pheromones of release new to path corresponding with history optimal solution, so that the path that history optimal solution is marked Information cellulose content is higher and higher, to achieve the purpose that algorithmic statement, the global information element updates rule is defined as:
Wherein, α ∈ [0,1] is the parameter of a control pheromones rate of decay, and r is ΓHIn an internal node, s It is one of child node of r, APSChIt is the fitness of history optimal solution, γrIt is the leaf section since all branches r Point sum.
Further, in step (3), the iteration optimal solution of therefrom selecting is updated to compared with history optimal solution Global optimum's path tree specifically includes:
A set { T is deconstructed by all equivalent current iterations are optimalI, and with all equivalent history optimal solution T Disaggregation { the T of compositionHCompare, { the THIndicated with tree, referred to as history optimal path tree ΓH, the root node of tree is figure G node v-1, from v-1To a complete branching representation one equivalent history optimal solution T of each leaf node;
If APSC ({ TI) > APSC ({ TH), then original history optimal solution set { THTo be emptied, { TIWill assignment To { TH}:
{TH}←{TI} (7);
If APSC ({ TH) < APSC ({ TI), then original { THRemain unchanged;
If APSC ({ TI)=APSC ({ TH),Then { THAbsorb { TIIn it is all Non-critical equivalent solution T 'I:
{TH}←{TI}U{TH} (8);
If APSC ({ TI) > APSC ({ TH),T′I∈{TH, original { THRemain unchanged.
Further, if APSC ({ TI)=APSC ({ TH),{TIIn it is non-critical Equivalent solution will be added into ΓHIn, specifically include step:
(1) initialization counter i=1;
(2) judge non-critical equivalent solution T 'II-th of element whether in history optimal path tree ΓHI-th layer in, if It is that step (2) are then returned to after i=i+1;If it is not, then skipping to step (3);
(3) non-critical equivalent solution T 'IIn from i+1 element to the segment of a last element as ΓHNew point Branch, is linked into ΓHThe i-th floor interior joint number be equal to T 'IIn i-th element node below.
Further, in step (3), the local search approach based on sequence specifically includes step:
(1) initialization counter i=1 and setCalculate the length L of solution T ';
(2) initialization counter j=L;
(3) ifStep (4) are then skipped to, otherwise j=j-1, returns to step (3);
(4) it enablesThen t is exchangediWith tj-1Position;
(5) j=j-1 skips to step (6) if j≤i, otherwise returns to step (3);
(6) otherwise i=i+1 skips to step (2) if i > L-1, terminates algorithm
Wherein, T ' is the solution of a given priorities of test cases sequencing problem based on covering, while assuming that T ' is Globally optimal solution then hastj∈ T ', i ≠ j, if pri (ti) > pri (tj), thenWherein, pri (ti) that calculate is tiPriority, i.e. tiPosition in T ',Indicate tiAdditional sentence cover collection, | | | | calculate it is defeated Enter the element number in set.
Compared with prior art, ACS algorithm of the invention is a kind of intelligent algorithm based on pheromones, is being searched for Cheng Zhong Utilizing question relevant knowledge and historical experience information can be optimized simultaneously, thus have stronger global search energy Power;In order to further increase the ability of searching optimum and efficiency of algorithm, the present invention introduces one kind in ACS algorithm and is based on The heuristic function that additional sentence covers and the local search approach based on sequence, effectively increase the solution efficiency of algorithm and ask Performance is solved, the regression test efficiency to software is further improved.
Detailed description of the invention
Fig. 1 is the flow chart that priorities of test cases sequence is carried out based on ant group algorithm of the embodiment of the present invention.
Specific embodiment
Method of the invention is further described with reference to the accompanying drawing.
Consider tested program a P, a test suite T={ t comprising n test case with m line statement1, t2..., tn, about all displaced set PT of T, the fitness function f of real number value, test case are mapped to from the displacement of T Priority ranking problem can be defined as: a displacement T ' ∈ PT is found, so thatT " ≠ T ', meets f (T ') ≥f(T″)。
It is an object of the present invention to maximize the sentence of test suite covering rate, i.e., by adjusting test case in test suite Sequence is executed, so that test suite covers all executable lines of codes in tested program as early as possible.For the target, we use language Sentence covering average percent is as fitness function of the invention, to assess the fine or not degree of construction solution.The calculation formula of APSC It is as follows:
Wherein TSiFor sentence i (for example, TS at the time of the middle quilt of T ' covers for the first time2=5 indicate sentences 2 by the in T ' Five test cases cover for the first time).The value range of APSC value is (0,1), and APSC value is bigger, indicates that test suite covers source program The rate of middle sentence is faster.
The priorities of test cases sequencing problem for maximizing sentence covering rate can be converted into following optimization problem: maximizeIt is limited toWherein tiI-th of test case in test suite after indicating sequence, Φ(ti) indicate implementation of test cases tiThe additional sentence covering number obtained afterwards.
Total sentence covering number of test case is sentence sum, additional sentence performed by tested program when testing the use-case It covers several, refers in above-mentioned sentence, the sentence number being performed for the first time when testing the test case, i.e., before the use-case The sentence that all test cases of test were all not carried out.Therefore, total sentence of test case covers several and test case sheet Body is related, and additional sentence covers several then locating in the test suite to have sorted with total sentence covering number and the test case simultaneously Position it is related.
Fig. 1 gives the flow chart of inventive algorithm optimal inspection use-case priority ranking problem.Below with regard to flow chart Content substep describes the specific embodiment of entire algorithm:
As shown in Figure 1, a kind of regression testing method that priorities of test cases sequence is carried out based on ant group algorithm, including step It is rapid:
(1) test suite comprising n test case, the corresponding tested program comprising m sentence is converted into figure G, Calculate first history optimal solutionAnd using its fitness as the pheromones initial concentration τ of figure G0, instantiate all artificial Ant;
(2) human oasis exploited starts to travel round figure G with the solution of construction problem, before the transfer of ant state each time, artificial ant Ant calculates the heuristic information of all both candidate nodes, and picks out next target that will be shifted according to pseudorandom ratio rules Node;After completing primary transfer, local information element, which updates rule, will act on the side shifted to reduce its pheromones Content;Later, ant judges whether to cover all sentences, if it is not, then continuing to shift;If so, stopping traveling round, step is gone to (3);
(3) after all human oasis exploiteds all complete the work of construction solution, the local search approach based on sequence is applied to Finely tune the solution of all generations;After this, the fitness of all solutions will be calculated, and therefrom select iteration optimal solution to history Optimal solution compares, and updates global optimum's path tree;It will be to update institute in figure G finally, updating rule by global information element There is the information cellulose content on side;
(4) it is terminated if algorithm reaches termination condition, the test suite after being sorted, otherwise return step (2);
(5) detection of regression test is successively carried out to software using the test suite after sequence as test case, it is ensured that software The correctness of new function and original function.
Below by it is of the invention based on ant group algorithm carry out priorities of test cases sequence regression testing method do into Explanation is developed in details in one step.
1, it initializes.
In the present invention, one comprising n test case, it is corresponding include that the test suite of tested program of m sentence will be by It is converted into figure G={ V, E }.V={ v-1, v1, v2..., vnIt is the node collection of figure G, wherein including n physical node v1, v2..., vn, respectively correspond n test case and a dummy node v-1Search starting point as all human oasis exploiteds.E={ Ev, ErBe Scheme the side collection of G, wherein Ev={ e (- 1,1), e (- 1,2) ..., e (- 1, n) } includes all from dummy node direction physical node Side, ErInclude the real side between all physical nodes.
In addition, each physical node v in figure Gi(i=1 2 ..., n) has its corresponding covering statement listJ is viTotal covering sentence number, sik, (1≤k≤j) is viCovering Line number of the kth sentence in tested program.During a construction solution, arbitrary node at most can only be by each ant in G Ant accesses once respectively.The sequence that ant accesses G interior joint in it is traveled round is the one of priorities of test cases sequencing problem A feasible solution.Since priorities of test cases ordering techniques do not give up test case, theoretically only when ant has traversed a G In after all nodes, the process of construction solution just calculates completion.However, in most cases, human oasis exploited is traversing all sections All sentences in tested program can be covered before point, and the sequence of remaining node after this there is not the quality of last solution Have an impact.Therefore, for the considerations of saving computing resource, in the present invention, human oasis exploited is in covering all sentences of tested program It can stop traveling round after (realize and rate is completely covered), remaining not visited node will be added to structure according to node number ascending order Make Xie Houfang.
First history optimal solutionDetermine the pheromones initial concentration τ of figure G0And local information element updates rule In pheromones increment.It is constructed by following steps:
(1) its additional sentence is calculated to all test cases for being not belonging to construction solution and covers number.
(2) use-case is randomly choosed from all additional test cases of the sentence covering number greater than 0, construction solution is added End.
(3) the total covering sentence number for calculating construction solution returns to step (1), otherwise if being less than the total sentence number of tested program Terminate.
The pheromones initial concentration of G
2, based on the heuristic function of additional coverage
In the present invention, each human oasis exploited k has the covering sentence collection of its ownTo record it in the mistake traveled round The tested program sentence covered in journey is not completely cured and is updated according to the new test case being added in construction solution to it, Update mode is as follows:
Wherein,Indicate the new test case v being added into construction solutions, calculate beWithDifference set.
One heuristic function relevant to problem has measured the excellent of the candidate test case that each is added into solution Bad degree.It is extremely important in ACS algorithm properly to define heuristic function, because this is related in construction solution preocess Each of locally optimal solution selection mode.Itself covering sentence collection based on human oasis exploitedAdditional sentence covering Heuristic function calculates as follows:
Wherein, S is all sentence collection of tested program, | | | | calculate the element number in input set.ηk(s) it measures Be cost that ant k is transferred to node s.The covering sentence collection of s is addedComprising the still unlapped sentence of many ant k, then The value of heuristic function η is larger, and ant k will be considered that s is the node highly shifted.If on the contrary, ηk(s) value is very Small, this shows the covering sentence collection of sMost of sentence of sum had all been covered by k, then k, which will be considered that, is less worth turning Move on to s.According to above-mentioned heuristic rule, the cost metric (i.e. distance) for scheming any a line e (r, s) in G can pass through following formula meter It calculates:
The distance δ of side e (r, s)k(r, s) is not a fixed value, but according to creeped ant it is different without Together.In the present invention, all human oasis exploiteds are all based on itself covering sentence collectionThe case where, treat figure G's from the visual angle of oneself Structure.This make same figure G may possess in different two ants eyes it is different in collection and each while distance; If the covering sentence collection of ant kMany of covering sentence collection with node sThe element of coincidence, k will be considered that node s Distance it is very remote;And if the covering sentence collection of ant k+1WithRepeat element it is seldom, k+1 will be considered that s from It is close.
In ACS algorithm, human oasis exploited selects next node definition to be accessed by pseudorandom ratio rules It is as follows:
Wherein, r is the node that ant is currently located, and τ (r, t) is the information cellulose content on the path of node r to t, and β is one The parameter of the relative importance of a control pheromones and heuristic information;Q is an equally distributed random number, and value range is [0,1], q0It is a parameter on 0 to 1, plays threshold function.When q is less than or equal to q0When, s, which is equal to, obtains maximum [τ (r, t)] [ηk(t)] that node of β value, otherwise s is equal to the random number for obeying probability distribution generation in following formula:
In formula (6), possess the β power product of biggish information cellulose content and heuristic information node will have it is bigger Probability is selected.By the integrated use of formula (5) and formula (6), ant can be maintained at most of the time history optimal solution institute It walks on the path of instruction, and it is unknown to explore those with certain probability, it is possible to constitute the node of more excellent solution.
3, pheromones and history optimal path tree
In the present invention, all solutions for possessing identical fitness are referred to as equivalent solution, and two possess completely the same survey The solution of example sequence on probation is referred to as stringent equivalent solution each other.During each iteration, when all human oasis exploiteds all construct After respective solution, all equivalent current iteration optimal solutions will constitute a set { TI, and most with all equivalent history Excellent disaggregation { the T being deconstructed intoHCompare, it is happened at this time there are four types of possible:
(1)APSC({TI) > APSC ({ TH});
(2)APSC({TH) < APSC ({ TI});
(3)APSC({TI)=APSC ({ TH),
(4)APSC({TI) > APSC ({ TH }),T′I∈{TH}。
In situation (1), original history optimal solution set { THTo be emptied, { TI{ T will be assigned toH, such as formula (7) It is shown;In situation (3), { THAbsorb { TIIn all non-critical equivalent solutions, as shown in formula (8);For situation (2) and (4), original { THRemain unchanged.
{TH}←{TI} (7)
{TH}←{TI}U{TH} (8)
In the present invention, { THIndicated with tree, referred to as history optimal path tree ΓH.The root node of tree is figure G section Point v-1, from v-1To a complete branching representation one equivalent history optimal solution T of each leaf node.For situation (3), {TIIn non-critical equivalent solution will be added into ΓHIn, concrete mode is as follows:
(1) initialization counter i=1.
(2) judge non-critical equivalent solution T 'II-th of element whether in history optimal path tree ΓHI-th layer in, if It is that step (2) are then returned to after i=i+1;If it is not, then skipping to step (3).
(3) T 'IIn from i+1 element to the segment of a last element as ΓHNew branch, be linked into ΓH's I-th floor interior joint number is equal to T 'IIn i-th element node below.
In ant group algorithm, pheromone updating rule determines that pheromones in environment change over time and dissipates or enhance Mode.By the dissipation and enhancing of pheromones, Artificial Ant Colony can converge to an approximation good enough most after many iterations In excellent solution.ACS algorithm has used two kinds of Pheromone update modes, and respectively global information element updates rule and part letter Breath element updates rule.The effect that global information element updates rule is discharged simultaneously by the pheromones in evaporation figure G on all sides In new pheromones to path corresponding with history optimal solution, so that the routing information cellulose content that history optimal solution is marked is got over Come it is higher, to achieve the purpose that algorithmic statement;Local information element updates rule by when ant shifts each time It waits, the information cellulose content in that corresponding a line is shifted in evaporation, avoids subsequent ant and follows identical track of creeping, reaches Algorithm search is dissipated, the purpose for falling into locally optimal solution is avoided.
In the present invention, global information element updates rule is defined as:
Wherein, α ∈ [0,1] is the parameter of a control pheromones rate of decay, and r is ΓHIn an internal node, s It is one of child node of r, APSChIt is the fitness of history optimal solution, γrIt is the leaf section since all branches r Point sum.Since a same side e (r, s) is possible to repeatedly appear in ΓHIn different places, therefore same side may It is updated several times in a global information element renewal process.
Local information element updates rule and is defined as follows:
τ (r, s) ← (1- ρ) τ (r, s)+ρ τ0#(10)
Wherein, ρ is similar with α, and the parameter of control pheromones rate of decay.τ0It is the pheromones initial concentration of figure G.
4, local search
Present invention demonstrates that globally optimal solution must satisfy following in the priorities of test cases sequencing problem based on covering Theorem: the solution T ' of a given priorities of test cases sequencing problem based on covering, while assuming that T ' is globally optimal solution, then HaveIf pri (ti) > pri (tj), thenWherein, pri (ti) calculate It is tiPriority, i.e. tiPosition in T ',Surely show tiAdditional sentence cover collection, | | | | calculate input set in Element number.
The theorem is the optimal sufficient conditions for solution of priorities of test cases sequencing problem based on covering.Based on the theorem, The present invention devises a kind of local search approach based on sequence, the specific steps are as follows:
(1) initialization counter i=1 and setCalculate the length L of solution T '.
(2) initialization counter j=L.
(3) ifStep (4) are then skipped to, otherwise j=j-1, returns to step (3).
(4) it enablesThen t is exchangediWith tj-1Position.
(5) j=j-1.If j≤i, step (6) are skipped to, otherwise return to step (3).
(6) i=i+1.If i > L-1, terminates algorithm, step (2) are otherwise skipped to.
In the worst cases, the time complexity of this local search approach is O (mL2), wherein m is the sentence of tested program Total line number.However, in practical applications, due to the effect of the heuristic rule based on additional coverage, the feasible solution of ant construction In most of adjacent test case tiAnd tjAll meetThis makes a series of set of step (4) Operation and final swap operation rarely have generation, and then the elapsed time of local search lessens.Nevertheless, experiments have shown that The local search approach based on sequence can significantly improve the search efficiency of ant group algorithm, shorten the convergence time of algorithm.This is Because this searching algorithm provides a kind of mechanism of fine tuning, so that some original fitness are not high enough, but can be by adjusting one The solution that the mode of point test case position improves fitness is found, to enhance the search energy of entire ant colony indirectly Power.The algorithm essence of the local search approach is to use classical bubble sort technology, while three kinds of set operations being inserted into Each time in swap operation.
Parameter setting of the invention are as follows: ant number N=16, β=2, q0=0.9, α=ρ=2.Final result shows, this Invention does not fall into suboptimization in many experiments, and average effect of optimization is better than traditional additional greedy algorithm, something lost Propagation algorithm and a kind of ant group algorithm mutation being recently proposed.This explanation solves regression test case priority ranking using the present invention Problem is highly effective.
Method proposed by the invention introduces the heuristic function based on additional coverage and the local search based on sequence Method significantly enhances search performance, improves the efficiency of search and regression test, is widely used in regression test with three and grinds The small programs studied carefully are as benchmark problem, while using the large program of an European Space Agency exploitation as practical problem, this hair It is highly effective that the positive research of bright progress, which demonstrates proposed method,.
The above description is merely a specific embodiment.But the scope of the present invention is not limited thereto.It is any ripe Know those skilled in the art within the technical scope of the present disclosure, any changes or substitutions that can be easily thought of, should all contain Lid is within protection scope of the present invention.

Claims (10)

1. a kind of regression testing method for carrying out priorities of test cases sequence based on ant group algorithm, which is characterized in that including step It is rapid:
(1) test suite comprising n test case, the corresponding tested program comprising m sentence is converted into figure G, calculated First history optimal solutionAnd using its fitness as the pheromones initial concentration τ of figure G0, instantiate all human oasis exploiteds;
(2) human oasis exploited starts to travel round figure G with the solution of construction problem, before the transfer of ant state each time, human oasis exploited meter The heuristic information of all both candidate nodes is calculated, and picks out next target section that will be shifted according to pseudorandom ratio rules Point;After completing primary transfer, local information element update rule will act on the side shifted and be contained with reducing its pheromones Amount;Later, ant judges whether to cover all sentences, if it is not, then continuing to shift;If so, stopping traveling round, step (3) are gone to;
(3) after all human oasis exploiteds all complete the work of construction solution, the local search approach based on sequence is applied to fine tuning The solution of all generations;After this, the fitness of all solutions will be calculated, and therefrom select iteration optimal solution to optimal with history Solution compares, and updates global optimum's path tree;It will be to update all sides in figure G finally, updating rule by global information element Information cellulose content;
(4) it is terminated if algorithm reaches termination condition, the test suite after being sorted, otherwise return step (2);
(5) detection of regression test is successively carried out to software using the test suite after sequence as test case, it is ensured that the new function of software It can be with the correctness of original function.
2. the regression testing method according to claim 1 that priorities of test cases sequence is carried out based on ant group algorithm, It is characterized in that, in step (1), the test one comprising n test case, the corresponding tested program comprising m sentence Set is converted into figure G and specifically includes:
By one comprising n test case, it is corresponding include m sentence tested program test suite will be converted into figure G=V, E }, wherein V={ v-1, v1, v2..., vnBe figure G node collection, it includes n physical node v1, v2..., vn, respectively correspond n A test case and a dummy node v-1As the search starting point of all human oasis exploiteds, E={ Ev, ErBe figure G side collection, Wherein Ev={ e (- 1,1), e (- 1,2) ..., e (- 1, n) } includes all sides that physical node is directed toward from dummy node, ErComprising all Real side between physical node;Scheme each physical node v in Gi(i=1 2 ..., n) has its corresponding covering statement listJ is viTotal covering sentence number, sik, (1≤k≤j) is viCovering Line number of the kth sentence in tested program.
3. the regression testing method according to claim 1 that priorities of test cases sequence is carried out based on ant group algorithm, It is characterized in that, in step (1), first history optimal solution of the calculatingAnd it is risen using its fitness as the pheromones of figure G Beginning concentration τ0, it instantiates all human oasis exploiteds and specifically includes:
1) its additional sentence is calculated to all test cases for being not belonging to construction solution and covers number;
2) a use-case is randomly choosed from all additional test cases of the sentence covering number greater than 0, the end of construction solution is added;
3) total covering sentence number of construction solution is calculated, if being less than the total sentence number of tested program, return step 1), otherwise terminate to count It calculates, obtains first history optimal solution
4) according to a history optimal solutionCalculate the pheromones initial concentration of G
4. the regression testing method according to claim 1 that priorities of test cases sequence is carried out based on ant group algorithm, It is characterized in that, in step (2), when the human oasis exploited calculates the heuristic information of all both candidate nodes,
The covering sentence collection of its own is arranged in each human oasis exploited kIt has been covered with recording it during traveling round Tested program sentence, be not completely cured and it be updated according to the new test case that is added in construction solution, update mode is as follows It is shown:
Wherein,Indicate the new test case v being added into construction solutions, calculate beWithDifference set;
Itself covering sentence collection based on human oasis exploitedThe heuristic function of additional sentence covering calculates as follows:
Wherein, S is all sentence collection of tested program, | | | | calculate the element number in input set, ηk(s) for measuring Be cost that ant k is transferred to node s, ηk(s) size determines whether ant k is worth being transferred to node;
According to above-mentioned heuristic rule, the cost metric (i.e. distance) for scheming any a line e (r, s) in G can be calculate by the following formula:
Wherein, the distance δ of side e (r, s)k(r, s) is not a fixed value, but according to creeped ant it is different without Together.
5. the regression testing method according to claim 1 that priorities of test cases sequence is carried out based on ant group algorithm, It is characterized in that, it is described to pick out next destination node definition that shifted such as according to pseudorandom ratio rules in step (2) Under:
Wherein, r is the node that ant is currently located, and τ (r, t) is the information cellulose content on the path of node r to t, and β is a control The parameter of the relative importance of pheromones and heuristic information processed;Q is an equally distributed random number, value range be [0, 1], q0It is a parameter on 0 to 1, plays threshold function;When q is less than or equal to q0When, s, which is equal to, obtains maximum [τ (r, t)] [ηk(t)] that node of β value, otherwise it is raw by probability distribution in following formula to be equal to random number a S, the random number S by s At random number:
In formula, Jk(r) indicate the set of all non-accessed nodes being connected with r, be connected with biggish information cellulose content with it is heuristic The node of the β power product of information will have bigger probability to be selected.
6. the regression testing method according to claim 1 that priorities of test cases sequence is carried out based on ant group algorithm, It is characterized in that, in step (2), the local information element updates rule by evaporating when ant shifts each time The information cellulose content in that corresponding a line is shifted, subsequent ant is avoided and follows identical track of creeping, reach diverging and search Rope avoids the purpose for falling into locally optimal solution, and the local information element updates rule and is defined as follows:
τ (r, s) ← (1- ρ) τ (r, s)+ρ τ0
Wherein, [0,1] ρ ∈ is the parameter for controlling pheromones rate of decay, τ0It is the pheromones initial concentration of figure G.
7. the regression testing method according to claim 1 that priorities of test cases sequence is carried out based on ant group algorithm, It is characterized in that, in step (3), the global information element updates rule by the pheromones on all sides in evaporation figure G, releases simultaneously It puts in new pheromones to path corresponding with history optimal solution, so that the routing information cellulose content that history optimal solution is marked Higher and higher, to achieve the purpose that algorithmic statement, the global information element updates rule is defined as:
Wherein, α ∈ [0,1] is the parameter of a control pheromones rate of decay, and r is ΓHIn an internal node, s is r One of child node, APSChIt is the fitness of history optimal solution, γrIt is that leaf node since all branches r is total Number.
8. the regression testing method according to claim 1 that priorities of test cases sequence is carried out based on ant group algorithm, It is characterized in that, in step (3), the iteration optimal solution of therefrom selecting updates global optimum to compared with history optimal solution Path tree specifically includes:
A set { T is deconstructed by all equivalent current iterations are optimalI, and constituted with all equivalent history optimal solution T Disaggregation { THCompare, { the THIndicated with tree, referred to as history optimal path tree ΓH, the root node of tree is figure G node v-1, from v-1To a complete branching representation one equivalent history optimal solution T of each leaf node;
If APSC ({ TI) > APSC ({ TH), then original history optimal solution set { THTo be emptied, { TIWill be assigned to {TH}:
{TH}←{TI}(7);
If APSC ({ TH) < APSC ({ TI), then original { THRemain unchanged;
IfThen { THAbsorb { TIIn institute There is non-critical equivalent solution T 'I:
{TH}←{TI}U{TH}(8);
IfOriginal { THRemain unchanged.
9. the regression testing method according to claim 8 that priorities of test cases sequence is carried out based on ant group algorithm, It is characterized in that, if{TIIn it is non-critical equivalent Solution will be added into ΓHIn, specifically include step:
(1) initialization counter i=1;
(2) judge non-critical equivalent solution T 'II-th of element whether in history optimal path tree ΓHI-th layer in, if so, Step (2) are then returned to after i=i+1;If it is not, then skipping to step (3);
(3) non-critical equivalent solution T 'IIn from i+1 element to the segment of a last element as ΓHNew branch, connect Enter to ΓHThe i-th floor interior joint number be equal to T 'IIn i-th element node below.
10. the regression testing method according to claim 1 that priorities of test cases sequence is carried out based on ant group algorithm, It is characterized in that, in step (3), the local search approach based on sequence specifically includes step:
(1) initialization counter i=1 and setCalculate the length L of solution T ';
(2) initialization counter j=L;
(3) ifStep (4) are then skipped to, otherwise j=j-1, returns to step (3);
(4) it enablesThen t is exchangediWith tj-1 Position;
(5) j=j-1 skips to step (6) if j≤i, otherwise returns to step (3);
(6) otherwise i=i+1 skips to step (2) if i > L-1, terminates algorithm
Wherein, T ' is the solution of a given priorities of test cases sequencing problem based on covering, while assuming that T ' is global Optimal solution then hasIf pri (ti) > pri (tj), thenWherein, pri (ti) that calculate is tiPriority, i.e. tiPosition in T ',Indicate tiAdditional sentence cover collection, | | | | calculate it is defeated Enter the element number in set.
CN201910254057.7A 2019-03-30 2019-03-30 Regression testing method for carrying out test case priority ranking based on ant colony algorithm Expired - Fee Related CN110109822B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910254057.7A CN110109822B (en) 2019-03-30 2019-03-30 Regression testing method for carrying out test case priority ranking based on ant colony algorithm

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910254057.7A CN110109822B (en) 2019-03-30 2019-03-30 Regression testing method for carrying out test case priority ranking based on ant colony algorithm

Publications (2)

Publication Number Publication Date
CN110109822A true CN110109822A (en) 2019-08-09
CN110109822B CN110109822B (en) 2022-03-29

Family

ID=67484872

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910254057.7A Expired - Fee Related CN110109822B (en) 2019-03-30 2019-03-30 Regression testing method for carrying out test case priority ranking based on ant colony algorithm

Country Status (1)

Country Link
CN (1) CN110109822B (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111209192A (en) * 2019-12-30 2020-05-29 山东科技大学 Test case automatic generation method based on double-chaos whale optimization algorithm
CN111598465A (en) * 2020-05-19 2020-08-28 华南理工大学 Multi-station multi-parameter task scheduling method for testing power lithium battery module
CN111666212A (en) * 2020-05-28 2020-09-15 平安医疗健康管理股份有限公司 Method, apparatus, device and medium for generating test case by ant colony algorithm
CN111666221A (en) * 2020-07-03 2020-09-15 西安邮电大学 Software test data set amplification method based on longicorn stigma search
CN111949552A (en) * 2020-09-03 2020-11-17 Oppo广东移动通信有限公司 Test case set generation method and device, computer equipment and storage medium
CN113268494A (en) * 2021-05-24 2021-08-17 中国联合网络通信集团有限公司 Statement processing method and device for database to be optimized
CN113419947A (en) * 2021-06-02 2021-09-21 山东科技大学 Regression test case priority ranking method based on improved ant colony algorithm
CN113742206A (en) * 2020-05-27 2021-12-03 南京大学 Test case priority algorithm selection method based on project characteristics

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120192153A1 (en) * 2011-01-25 2012-07-26 Verizon Patent And Licensing Inc. Method and system for providing a testing framework
CN104820636A (en) * 2015-04-09 2015-08-05 北京轩宇信息技术有限公司 Ant colony algorithm based parallel test case sequence generation method
CN107816999A (en) * 2017-09-25 2018-03-20 华南理工大学 A kind of unmanned boat navigation path contexture by self method based on ant group algorithm

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120192153A1 (en) * 2011-01-25 2012-07-26 Verizon Patent And Licensing Inc. Method and system for providing a testing framework
CN104820636A (en) * 2015-04-09 2015-08-05 北京轩宇信息技术有限公司 Ant colony algorithm based parallel test case sequence generation method
CN107816999A (en) * 2017-09-25 2018-03-20 华南理工大学 A kind of unmanned boat navigation path contexture by self method based on ant group algorithm

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
孟凡聪: "一种基于排序奖惩的蚁群算法", 《脑知识与技术》 *

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111209192A (en) * 2019-12-30 2020-05-29 山东科技大学 Test case automatic generation method based on double-chaos whale optimization algorithm
CN111598465A (en) * 2020-05-19 2020-08-28 华南理工大学 Multi-station multi-parameter task scheduling method for testing power lithium battery module
CN111598465B (en) * 2020-05-19 2023-03-31 华南理工大学 Multi-station multi-parameter task scheduling method for testing power lithium battery module
CN113742206A (en) * 2020-05-27 2021-12-03 南京大学 Test case priority algorithm selection method based on project characteristics
CN111666212A (en) * 2020-05-28 2020-09-15 平安医疗健康管理股份有限公司 Method, apparatus, device and medium for generating test case by ant colony algorithm
CN111666221A (en) * 2020-07-03 2020-09-15 西安邮电大学 Software test data set amplification method based on longicorn stigma search
CN111666221B (en) * 2020-07-03 2022-09-27 西安邮电大学 Software test data set amplification method based on longicorn stigma search
CN111949552A (en) * 2020-09-03 2020-11-17 Oppo广东移动通信有限公司 Test case set generation method and device, computer equipment and storage medium
CN113268494A (en) * 2021-05-24 2021-08-17 中国联合网络通信集团有限公司 Statement processing method and device for database to be optimized
CN113268494B (en) * 2021-05-24 2023-06-02 中国联合网络通信集团有限公司 Method and device for processing database statement to be optimized
CN113419947A (en) * 2021-06-02 2021-09-21 山东科技大学 Regression test case priority ranking method based on improved ant colony algorithm
CN113419947B (en) * 2021-06-02 2024-04-16 山东科技大学 Regression test case priority ordering method based on improved ant colony algorithm

Also Published As

Publication number Publication date
CN110109822B (en) 2022-03-29

Similar Documents

Publication Publication Date Title
CN110109822A (en) The regression testing method of priorities of test cases sequence is carried out based on ant group algorithm
Ma et al. Online planner selection with graph neural networks and adaptive scheduling
Martinez et al. Lights and shadows in Evolutionary Deep Learning: Taxonomy, critical methodological analysis, cases of study, learned lessons, recommendations and challenges
CN103810104A (en) Method and system for optimizing software test case
Mangharam et al. Anytime algorithms for GPU architectures
Vallati et al. What you always wanted to know about the deterministic part of the international planning competition (IPC) 2014 (but were too afraid to ask)
Crawford et al. A hyperheuristic approach for dynamic enumeration strategy selection in constraint satisfaction
Ansótegui et al. Reactive dialectic search portfolios for MaxSAT
Jackson et al. Late acceptance-based selection hyper-heuristics for cross-domain heuristic search
Mezzasalma et al. Cold-blooded in the Ice Age:“refugia within refugia”, inter-and intraspecific biogeographic diversification of European whipsnakes (Squamata, Colubridae, Hierophis)
Seipp et al. Fast downward aidos
CN106095684A (en) A kind of predictability mutation testing method
CN111553509B (en) Rail transit route selection evaluation and cost optimization method aiming at geological environment risk
Sajadi et al. A new fuzzy multi-objective multi-mode resource-constrained project scheduling model
Wang et al. Learning to traverse over graphs with a Monte Carlo tree search-based self-play framework
Domshlak et al. Online speedup learning for optimal planning
Chen et al. LOGER: A learned optimizer towards generating efficient and robust query execution plans
CN105930272A (en) Important statement-based branch coverage testing data generation method
Kareem et al. Evaluation Of Bayesian Network Structure Learning
CN110377492A (en) A kind of unit testing case generation method based on method similarity
CN116599886A (en) Network full-coverage path set selection method based on deep reinforcement learning
Díaz et al. An elitist seasonal artificial bee colony algorithm for the interval job shop
CN109726362A (en) Solve the local search method for solving and system for weighting maximum satisfiability problem
Adhitama et al. Hill climbing algorithm for Bayesian network structure
CN112181420A (en) Compiler defect positioning method based on reinforcement learning

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20220329

CF01 Termination of patent right due to non-payment of annual fee