Prioritization In Regression Testing Biology Essay

Published:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

The prioritization of test cases is very helpful way to reduce the cost of regression testing. Being a maintenance process, it requires additional resources and time. Therefore, it becomes challenge for software testers to complete Regression Testing effectively and on schedule.

In this paper, the Particle Swarm Optimization (PSO) technology has been studied and used with the blend of Genetic Algorithm (GA). Particle Swarm Optimization is an optimization algorithm based on heuristic search which will be used to solve time-constraint environment of test case prioritization. The concept of Genetic Algorithm will further help in diversifying the solution within whole search space.

Keywords: Regression Testing, Particle Swarm Optimization, Genetic Algorithms.

1. INTRODUCTION

In maintenance process, it is very hard (difficult) to decide which test case to run, or which test case to mark as effective in order to detect cause of modification in software. Regression Testing is a testing process, with in maintenance process, to assure that modification done in software has not over-ruled specification. To run each and very test case can become very time consuming task.

Therefore, to make it more scheduled many criteria's can be followed: reduction of test case, test case selection, prioritization of test cases. In this paper, we have concentrated our work in the area of "prioritization of test cases". It has been proved earlier, that, time-constrained test case prioritization is NP problem (ref). Thus, the optimization techniques have been used here, to make effective solution on-schedule.

These techniques used are: Particle Swarm Optimization (PSO) and Genetic Algorithm (GA) operator. The PSO is a global optimization algorithm based on heuristic search. The idea was given by John Kennedy and Eberhert, in 1995, after observing group of animals, flock of birds and fishes, where each individual follows the path of "global best" particle with in its population, e.g. in ocean, while searching for good food source (plankton), a school of fish, moves everywhere making cylindrical shape. The inside story: every fish is observing its neighbor's position and velocity then compare it with global best position and velocity. The "best" position and velocity is chosen and updates are made by individuals in their position and velocity. Thence, each fish converges towards the best position after modification in its velocity, which helps to move towards the food faster.

In this paper, we have blended the PSO with crossover operator of GA, to avoid group of population from converging to local best. The GA processor consists of: selection, crossover and mutation. In GA from general population, a set of best fitted population is selected on the basis of fitness function and crossover, mutation operators are applied to get optimal solution. The crossover operator helps in PSO to make each individual a widened look of search space, by crossing over them with other individuals.

The PSO has been applied to Traveling Salesman Problem (ref), Routing Optimization Problem (ref), NP Knapsack (ref) whereas GA is known for optimizing scheduling problems (ref). Here, we have tried to use combination of PSO and GA to solve, time-constrained prioritization. To make results effective, APFDs have been shown.

2. RELATED WORK

Many researchers have explored work in the field of PSO. Being an optimization approach it is used to solve routing optimization [223], job-scheduling [644], network security [471], cryptography and crypt-analysis [278], unsupervised robotic learning [422]. The GA is favorable field of many scientists, explorers and researchers, this makes application of GA in the diverse fields such as: Robotics, Evolvable Hardware, Optimized Telecommunicating Routing, Biomimetic Invention, Trip, Traffic and Shipment Routing, Regression Testing, Data Mining etc.

3. Particle Swarm Optimization

The PSO is technique for solving non-linear and discrete optimization problems (HPSO1, 21). The PSO technique starts with initialization of population (of particles), depending on the problem to be analyzed. Here, each individual (particle) represents a candidate solution. The particle in search space is denoted or stands for position with respect to other particles in population. Each particle has been assigned velocities that get updated while particle moves with in search space.

During evolution phase, the particles follow two best values :- (HPSO [8])

Pbest: - best solution that particle has achieved so far.

Gbest: - best solution achieved by population so far.

The updation in velocity of particles is done using equation:

Vik+1 = wVik +c1 rand1(…) x (pbesti-sik) + c2 rand2(…) x (gbest-sik) ….. (1)

where, vik : velocity of agent i at iteration k, w: weighting function, cj : weighting factor, rand : uniformly distributed random number between 0 and 1, sik : current position of agent i at iteration k, pbesti : pbest of agent i, gbest: gbest of the group.

The following weighting function is usually utilized in (1)

w = wMax-[(wMax-wMin) x iter]/maxIter (2)

where, wMax= initial weight,

wMin = final weight,

maxIter = maximum iteration number,

iter = current iteration number.

sik+1 = sik + Vik+1 (3)

More or less, PSO and GA share similarities: -

In PSO, principle of random initialization of population is used.

The concept of evolution and modification of population.

But PSO does not utilize GA operators (crossover, mutation). Instead of this, individuals in PSO update itself. This can lead them to converge for local maxima, as they won't get information of rest search space. In order, to diversify the search space of individual's, crossover operator has been combined with PSO technique. This will help population to fly in new search spaces, by swapping.

4. Genetics Algorithm

In early 1970's, Holland introduced concept of GA in his book "Adaptation in Natural and Artificial Systems", describing genetics and evolution as its basic concepts.

Till now, GA has been applied in many fields such as optimization design, fuzzy logic control, neural network, expert system, scheduling [gaPSO1 [16,17]].

The basics of GA:-

The chromosome (string like structure), that represents, a part of solution.

Selection Mechanism: - Here, the generated population has been initialized randomly.

Evaluation Mechanism: - Then, a fitness function is decided (depending on problem), that is further used to evaluate population. The individuals that fulfill the fitness function criteria are allowed to breed further.

Recombination Mechanism: - Here, crossover function is applied on new immediate population, by swapping two parent string. This mechanism generates two off-springs that are either promising solution or close to solution.

Mutation Mechanism: - The Mutation operator, is applied on promising off-spring to diversify its search space. It helps population to breed and reproduce in new search space with better solution.

GA consists of these mechanisms, with the help of them; optimized solutions are generated, after evaluating whole search space (possible solutions).

PROPOSED ALGORITHM

In PSO, while searching for best solution in the search space, the particle can converge towards point between particle best and local best (neighbor best), this results particle to converge towards single point, ignoring other aspects of search spaces (ignoring global best conditions).

To overcome this limitation, GA factor has been introduced in PSO concept. The reason to apply crossover [15] in PSO is to increase population diversity and ability of PSO to avoid local maxima [12] and making searching process fast.

Flowchart

Assumptions:

Test cases of given problem is equal to particles in population.

Initial population is generated randomly.

The position, velocity, fitness function and stopping criteria of particles depend on problem.

In our case,

Position= rank of test case based on fitness function

Velocity= number of faults or condition covered by a particle.

Input: Random number of test cases depending on problem.

Output: Test suite with minimum number of test cases and full-filling stopping criteria and fitness function.

ALGORITHM:

Initialization:

Set number of test cases= number of particles

For each particle

{

Initialize position

Initialize velocity

Initialize fitness-function

}

Application:

Do

{

Update position and velocity of each particle

(Depending on fitness-function).

Apply crossover operator on updated population

} while (stopping criteria not met)

End.

Explanation of Algorithm:

In the proposed algorithm of PSO with crossover operator, the random population is generated. The position and velocity of particle is initialized depending on problem. Beside this, the fitness function is also initialized, which helps the population to move towards solution iteratively. Then the PSO features are applied by every particle. The particles update individual position and velocity by comparing the particle best with local and global best respectively. When the updation of each particle ends, then apply Crossover operator over the new population generated, by dividing them in two parents and crossing over them. It will create, two new off-springs, then comparison between is done considering stopping criteria. If any of offspring fulfills the stopping criteria the algorithm stops, otherwise it will select best offspring and PSO applied again.

Mutation Testing:

The Software Testing is time consuming activity, as it requires testing all inputs of program and ensuring program produces expected results. To test perfectly, program is tested for every single input, whether inputs are valid or invalid. In a way to assess effectiveness of testing procedure, mutation testing intentionally seeds faults in to the code of program, may be to change logic of program. The Mutation testing can be used as quantifying measure for test cases. Test cases, which are not able to find mutant or "kill mutant" can be removed from test suite, that is, mutation testing is used to test the quality of your test suite. However, mutation testing is very expensive to run, especially on very large applications.

In Example 1 and 2, codes have been mutated by seeding 5 faults in them respectively.

The program in Example-1 deals with "University Admission in Courses" and Example-2 deals with "Hotel Reservation System" taken from http://www.planet-source-code.com.

Example 1:

In this problem, we have 9 test cases that need to be prioritized covering 5 faults respectively. In fault coverage testing, its rarely happens that one test case covers all faults. As described earlier, example is run on time-constrained environment. Every test case takes some time to execute all faults.

Here, Test Cases are {T1, T2, T3, T4, T5, T6, T7, T8, and T9} and the faults to be covered are {F1, F2, F3, F4, and F5}, as table shown below:

Test case/

Faults

F1

F2

F3

F4

F5

NO.OF FAULTSCOVERED

EXECUTION TIME (UNIT)

T1

X

X

X

X

4

11.5

T2

X

X

2

11.5

T3

X

X

X

3

12.33

T4

X

X

X

3

10.66

T5

X

1

15

T6

X

X

X

3

8.33

T7

X

1

15

T8

X

X

X

3

10

T9

X

1

11

APPLYING PSO TECHNIQUE ON ABOVE EXAMPLE:

Each particle will look for global test and local best and will update its position based on that. The condition covered is the criteria of selecting best. In algorithm, it has been assumed that test case will represent the particle and in the process of updation of position and velocity each particle will compare its best position with of neighbor's best and global best position.

TEST CASE

Particle Selection for best

T1

T1

T2

T2T1

T3

T3T1

T4

T4T1

T5

T5T1

T6

T6T1

T7

T7T1

T8

T8T1

T9

T9T1

After updating each particle following table will come. If its position has been improved after PSO, it retained otherwise original value is kept.

TEST CASE

Position Improved (Y/N)

Value retained or changed to original

T1

N

T1

T2T1

Y

T2T1

T3T1

Y

T3T1

T4T1

Y

T4T1

T5T1

Y

T5T1

T6T1

Y

T6T1

T7T1

Y

T7T1

T8T1

Y

T8T1

T9T1

Y

T9T1

Now, apply crossover operation on updated generation of population. To make two best test-suites out of these test cases.

By applying crossover operator the population is getting information about each particle with in search space.

After doing 1 point crossover we got:

{T1, T2T1, T7T1, T8T1, T9T1} and {T5T1, T6T1, T3T1, T1T4}

First test suite covers all paths in lesser time.

On removing duplicity:

TEST-SUITE A: T1, T8

Time Taken: 21.5s

TEST-SUITE B: T1, T4

Time Taken: 22.16s

TEST-SUITE A covers all faults with minimum execution time.

Example 2:

In this problem, we have 5 test cases that need to be prioritized covering 5 faults respectively. In fault coverage testing, its rarely happens that one test case covers all faults. As described earlier, example is run on time-constrained environment. Every test case takes some time to execute all faults.

Here, Test Cases are {T1, T2, T3, T4, T5} and the faults to be covered are {F1, F2, F3, F4, and F5}, as table shown below:

TEST CASE/FAULTS

F1

F2

F3

F4

F5

Total Faults Covered

Time of execution

T1

X

X

X

3

12.2

T2

X

1

10

T3

X

X

X

3

10.67

T4

X

1

7

T5

X

X

X

X

4

9.97

APPLYING PSO TECHNIQUE ON ABOVE EXAMPLE:

Each particle will look for global test and local best and will update its position based on that. The condition covered is the criteria of selecting best. Similar, to example-1.

TEST CASE

Particle Selection for best

T1

T1T5

T2

T2T5

T3

T3T5

T4

T4T5

T5

T5

After updating each particle following table will come. If its position has been improved after PSO, it retained otherwise original value is kept.

TEST CASE

Position Improved (Y/N)

Value retained or changed to original

T1T5

Y

T1T5

T2T5

Y

T2T5

T3T5

Y

T3T5

T4T5

Y

T4T5

T5

N

T5

Now, apply crossover operation on updated generation of population. To make two best test-suites out of these test cases.

After doing 1 point crossover we got:

{T1T5, T5} and {T4T5, T2T5, T3T5}

First test suite covers all paths in lesser time.

On removing duplicity:

TEST-SUITE A: T1, T5

Time Taken: 22.17s

TEST-SUITE B: T2, T3, T4, T5

Time Taken: 37.64s

TEST-SUITE A covers all faults with minimum execution time.

Code Coverage Testing (Path based):

The code coverage based testing consists of: branch coverage, flow coverage, condition coverage. The path coverage testing is also a form of code coverage where internal structure of program is analyzed. In path coverage testing, the numbers of independent paths are searched (McCabe, 1976). Each independent path assures covering at the least one condition.

According to McCabe, the basic path testing technique consists of for steps:

Computation of program graph.

Cyclomatic Complexity calculation.

Selection of Independent paths.

Generation of test cases covering each independent path.

Example 3:

In following example, code-coverage testing criteria have been done. The test case to be chosen should be those that cover all condition within the program has been used to prioritize test cases. The test suite to be chosen as solution should consist of test cases covering all independent paths and maximum condition and statement coverage.

For program graph see APPENDIX A. On the basis of program flow graph Cyclomatic complexity calculated is 6.

V (G)= e-n+p

Where,

e=23, n=18, p=1

Therefore, number of independent paths will be 7. Now, test cases are run for all number of independent paths to be covered ensuring that all conditions in the program have been covered.

Here, there are 19 test cases and 7 independent paths, as shown below in table.

Test Cases as follows:

T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19.

Independent Paths as follows:

abfgnpqr, abcdeghjkmqr, abcdeghimqr, abcdegnoqr, abcegnpqr, abcdeghjlmqr, abfgnoqr

TEST CASE NO.

X

Y

Z

EXPECTED OUTPUT

INDEPENDENT PATH

CONDITION COVERED

STATEMENT COVERED

1

50

50

0

INVALID INPUT

abfgnpqr

3

8

2

50

50

1

ISO

abcdeghjkmqr

5

12

3

50

50

2

ISO

abcdeghjkmqr

5

12

4

50

50

50

EQUI

abcdeghimqr

4

11

5

50

50

99

ISO

abcdeghjkmqr

5

12

6

50

50

100

NT A TRI

abcdegnoqr

4

10

7

50

50

101

INVALID INPT

abcegnpqr

4

9

8

50

0

50

INVALID INPT

abfgnpqr

3

8

9

40

20

30

SCALENE

abcdeghjlmqr

5

12

10

50

2

50

ISO

abcdeghjkmqr

5

12

11

50

99

50

ISO

abcdeghjkmqr

5

12

12

50

100

50

NT A TRI

abfgnoqr

3

8

13

50

101

50

INVALID INPT

abcegnpqr

4

9

14

0

50

50

INVALID INPT

abfgnpqr

3

8

15

1

50

50

ISO

abcdeghjkmqr

5

12

16

20

40

30

SCALENE

abcdeghjlmqr

5

12

17

80

50

80

EQUI

abcdeghimqr

4

11

18

100

50

50

NT A TRI

abcdegnoqr

4

9

19

101

50

50

INVALID INPT

abcegnpqr

4

9

The table below represents total condition covered, total node covered, total statement covered.

TEST CASES

INDEPENDENT PATH

CONDITION COVERED

NODES COVERED

STATEMENT COVERED

1

abfgnpqr

3

8

21

2

abcdeghjkmqr

5

12

23

3

abcdeghjkmqr

5

12

23

4

abcdeghimqr

4

11

22

5

abcdeghjkmqr

5

12

23

6

abcdegnoqr

4

10

21

7

abcegnpqr

4

9

20

8

abfgnpqr

3

8

21

9

abcdeghjlmqr

5

12

24

10

abcdeghjkmqr

5

12

23

11

abcdeghjkmqr

5

12

23

12

abfgnoqr

3

8

20

13

abcegnpqr

4

9

21

14

abfgnpqr

3

8

21

15

abcdeghjkmqr

5

12

23

16

abcdeghjlmqr

5

12

24

17

abcdeghimqr

4

11

22

18

abcdegnoqr

4

9

21

19

abcegnpqr

4

9

21

APPLYING PSO TECHNIQUE ON ABOVE EXAMPLE:

Each particle will look for global best and local best and will update its position based on number of condition covered. So, the path selected will be one which covers number of solution.

Here, there are 19 test cases and each test case compares its position with respect to all test cases. Test case T1 will compare global best and local best and update its position, velocity with local best T2. Similarly, for all test cases comparison is done.

TEST CASE

Particle Selection for best

T1

T1T2

T2

T2

T3

T3

T4

T4T5

T5

T5

T6

T6T5

T7

T7T5

T8

T8T9

T9

T9

T10

T10

T11

T11

T12

T12T11

T13

T13T11

T14

T14T15

T15

T15

T16

T16

T17

T17T16

T18

T18T16

T19

T19T16

After updating each particle following table will come. If its position has been improved after PSO, it retained otherwise original value is kept.

TEST CASE

Position Improved (Y/N)

Value retained or changed to original

T1T2

Y

T1T2

T2

N

T2

T3

N

T3

T4T5

N

T4

T5

N

T5

T6T5

Y

T6T5

T7T5

Y

T7T5

T8T9

Y

T8T9

T9

N

T9

T10

N

T10

T11

N

T11

T12T11

Y

T12T11

T13T11

N

T13

T14T15

Y

T14T15

T15

N

T15

T16

N

T16

T17T16

N

T17

T18T16

Y

T18T16

T19T16

Y

T19T16

Now, apply crossover operation on updated generation of population. To make two best test-suites out of these test cases. For applying crossover, the updated population is divided into two sets and crossed with each other.

Two-Point Crossover:

T10

T11

T3

T4

T5

T6T5

T7T5

T8T9

T9

T1T2

T2

T12T11

T13

T14T15

T15

T16

T17

T18T16

T19T16

Second table covers all independent paths and conditions:

On removing duplicity:

TEST-SUITE A: T10, T11, T3, T4, T5, T6, T7, T8, T9

TEST-SUITE B: T1, T2, T12, T13, T16, T17, T18

TEST-SUITE B covers all independent paths.

CONCLUSION:

The algorithm has been proposed to prioritize test cases using PSO technique along with crossover operator used in Genetic Algorithm. The prioritization has been done using two selection criteria namely: total fault coverage with in time constrained environment and code coverage testing. This algorithm uses the phenomena of convergence (PSO) while diversifying search space (GA operator) for regression testing. The effectiveness of algorithm has been shown with the help of APFD's values.

FUTURE WORK:

Here, the numbers of test cases taken in example are few, as the algorithm has been implemented manually. In future work, the algorithm would be automated in order to automate the process of Test Case Prioritization.

Writing Services

Essay Writing
Service

Find out how the very best essay writing service can help you accomplish more and achieve higher marks today.

Assignment Writing Service

From complicated assignments to tricky tasks, our experts can tackle virtually any question thrown at them.

Dissertation Writing Service

A dissertation (also known as a thesis or research project) is probably the most important piece of work for any student! From full dissertations to individual chapters, we’re on hand to support you.

Coursework Writing Service

Our expert qualified writers can help you get your coursework right first time, every time.

Dissertation Proposal Service

The first step to completing a dissertation is to create a proposal that talks about what you wish to do. Our experts can design suitable methodologies - perfect to help you get started with a dissertation.

Report Writing
Service

Reports for any audience. Perfectly structured, professionally written, and tailored to suit your exact requirements.

Essay Skeleton Answer Service

If you’re just looking for some help to get started on an essay, our outline service provides you with a perfect essay plan.

Marking & Proofreading Service

Not sure if your work is hitting the mark? Struggling to get feedback from your lecturer? Our premium marking service was created just for you - get the feedback you deserve now.

Exam Revision
Service

Exams can be one of the most stressful experiences you’ll ever have! Revision is key, and we’re here to help. With custom created revision notes and exam answers, you’ll never feel underprepared again.