Effective Black-Box Testing with Genetic Algorithms Mark Last and - - PowerPoint PPT Presentation

effective black box testing with genetic algorithms
SMART_READER_LITE
LIVE PREVIEW

Effective Black-Box Testing with Genetic Algorithms Mark Last and - - PowerPoint PPT Presentation

Dr. Mark Last (BGU) Effective Black-Box Testing with Genetic Algorithms Effective Black-Box Testing with Genetic Algorithms Mark Last and Shay Eyal Department of Information Systems Engineering Ben-Gurion University of the Negev, Beer-Sheva,


slide-1
SLIDE 1
  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Effective Black-Box Testing with Genetic Algorithms

Mark Last and Shay Eyal Department of Information Systems Engineering Ben-Gurion University of the Negev, Beer-Sheva, Israel Abraham Kandel National Institute for Systems Test and Productivity (NISTP) University of South Florida, Tampa, FL, USA IBM Verification Conference 2005

slide-2
SLIDE 2

2

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Agenda

  • What is NISTP?
  • Black-Box Testing: State-of-the-Art
  • Research Goal and Objectives
  • Overview of Genetic Algorithms (GA)

– Fuzzy-Based Age Extension of Genetic Algorithms (FAexGA)

  • GA-Based Test Case Generation
  • Initial Case Studies
  • Summary and Discussion
slide-3
SLIDE 3

3

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

National Institute for Systems Test and Productivity

  • University of South Florida, Tampa, FL, USA

– College of Engineering: PI - Prof. Abraham Kandel (Executive Director) – College of Business Administration: CO-PI - Prof. Alan R. Hevner

  • Subcontractors

– Arizona State University: PI - Dr. Wei-Tek Tsai – Drexel University: PI - Dr. Rosina Weber – QTSI: PI - Chick Garcia – Ben Gurion University: PI - Dr. Mark Last – Echelon: PIs - Dr. Jay Bayne, Dr. Norm Brown

Funding Source: SPAWAR - US Space and Naval Warfare Systems Command (Grant No. N00039-01-1-2248). WWW: http://nistp.csee.usf.edu/ The Institute's mission is to engage in innovative research and to provide direct support to government agencies (and their development agents) which will enable them to substantially reduce cost and improve the development schedule and reliability of large-scale systems

slide-4
SLIDE 4

4

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Functional (Black-Box) Testing

  • Based on software specification only
  • Compares the observed outputs to

expected outputs

  • Needs an “oracle” for a tested system
  • Exhaustive (combinatorial) testing is

computationally infeasible for large- scale software systems

  • BB Test generation methods

– Random Testing (within / without the

  • perational profile)

– Special value testing – Boundary value testing – Equivalence classes – Decision tables – Input-Output Analysis

I n p u t s O u t p u t s

All BB testing methods cover only a tiny portion of possible software inputs!

slide-5
SLIDE 5

5

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Effective Black-Box Test Cases

  • Test case

– A particular choice of input data to be used in testing a program

  • An effective set of test cases

– A test set that has a high probability of detecting faults presenting in a computer program

  • Testers’ Objectives

– Generate good test cases

  • A good test case is one that has a high probability of detecting an as-

yet undiscovered error

  • Several test cases causing the same bug may show a pattern that

might lead to the real cause of the bug

– Prioritize test cases

  • The dominant criterion: rate of fault detection – how quickly a test

case detect faults during the testing process

slide-6
SLIDE 6

6

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Research Goal and Objectives

  • Goal

– Develop novel methodology for generation of effective black-box test cases with genetic algorithms

  • Basic Idea

– Eliminate "bad" test cases that are unlikely to expose any error, while increasing the number of "good" test cases that have a high probability of producing an erroneous output

  • Objectives

– Define a general framework for evolving an effective set of test cases with a genetic algorithm – Enhance the proposed GA-based methodology by the novel Fuzzy- Based Age Extension of Genetic Algorithms (FAexGA) – Evaluate the effectiveness and the efficiency of the proposed approach using synthetic and real computer programs

slide-7
SLIDE 7

7

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Overview of Genetic Algorithms (GA)

  • Search and optimization method developed

by mimicking the evolutionary principles and chromosomal processing in natural genetics

  • Application Areas

– Optimization: numerical, combinatorial (job-shop scheduling). – Machine learning tasks: classification, prediction (weights for neural networks). – Economics: bidding strategies.

“ “Genetic algorithm is a computerized

Genetic algorithm is a computerized simulation of Darwin's theories simulation of Darwin's theories” ”

Holland J. H. Holland J. H.

slide-8
SLIDE 8

8

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Initialize Initialize population population Selection Selection Mutation Mutation Crossover Crossover Insert into Insert into population population

Select individuals for mating Mate individuals Mutate offspring

Insert offspring into population Stop criteria satisfied ?

Moving to Moving to the next the next generation generation… …

Answer

Yes No

GA Working Principle

slide-9
SLIDE 9

9

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

General GA Settings

  • Solution encoding (binary, real, tree…).
  • Initialization

– How to create an initial population of potential solutions?

  • Genetic operators

– Selection method (ranking, roulette wheel…). – Crossover-operator (one-point, uniform…). – Mutation-operator (inversion, flip…).

  • Evaluation function

– Rate the candidate solutions quality

  • Parameter values

– N - population size – Pc - crossover probability – Pm - mutation probability – Ngen – number of generations

slide-10
SLIDE 10

10

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Crossover and Mutation

100000011101000 100111100011100 100110011101000 100001100011100

Single-Point Crossover

000

001 010

011

100 101 111

110

?

Bit-flip Mutation

slide-11
SLIDE 11

11

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Premature Convergence of GAs

Parameters: population size, crossover probability, etc. Exploration – overall search in the solution space Exploitation – localized search in the promising

regions discovered so far in that space

“Poor parameter setting might make exploitation

/exploration relationship (EER) disproportionate, produce lack of diversity and lead to Premature Convergence”

  • F. Herrera
slide-12
SLIDE 12

12

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Fuzzy-Based Age Extension of Genetic Algorithms (FAexGA)

(Last and Eyal, 2005)

  • Goal

– Find an optimal policy for controlling the Exploration/Exploitation relationship in GA based on the age attribute.

  • Age = number of generations

Example: Example:

If A is If A is Old Old and B is and B is Old Old then then crossover probability is crossover probability is Low Low

Where A and B are two chromosomes chosen for crossover Where A and B are two chromosomes chosen for crossover

slide-13
SLIDE 13

13

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

FAexGA Method

  • Adapt the crossover probability (Pc) with

Fuzzy Logic Controller (FLC):

Knowledge Base Knowledge Base Fuzzification interface Fuzzification interface GA GA Defuzzification interface Defuzzification interface Inference System Inference System

State Variables Control Parameters

  • Crossover probability
  • Lifetime, Age.
slide-14
SLIDE 14

14

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Fuzzification of Age

  • Age ∈ [Young, Middle-age, Old]

Young Middle-age Old

0.2 0.5 1

Membership Function

1

Relative Age

(= age/avg. lifetime)

Young: 0-30% Middle-age: 20-80% Old: 70-100%

0.3 0.8 0.7

Lifetime = number of generations a chromosome stays alive

slide-15
SLIDE 15

15

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Fuzzification of Crossover Probability PC

  • Pc ∈ [Low, Medium, High]
  • Defuzzification method: Center of Gravity

Low Medium High

0.15 0.5 1

Membership Function

1

Pc Low: 0-20% Medium: 15-85% High: 80-100%

0.2 0.85 0.8

slide-16
SLIDE 16

16

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Fuzzy-Based Age Extension of GA

Random Random Initialize P(t) Initialize P(t)

P(t) = population on generation t.

Evaluate P(t) Evaluate P(t) Increase Age Increase Age Selection Selection Assign Pc Assign Pc Mutation Mutation Crossover Crossover Remove Individuals Remove Individuals with age > lifetime with age > lifetime Evaluate P(t) Evaluate P(t)

Answer Answer Answer Moving to Moving to the next the next generation generation… …

Stop criteria satisfied ? Call Fuzzy Logic Controller

slide-17
SLIDE 17

17

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Fuzzy Rule Base

  • Age ∈ [Young, Middle-age, Old]
  • Crossover Probability Pc ∈ [Low, Medium, High]
  • Inference method: MAX-MIN

Low Medium Low “Old” Medium High Medium “middle-age” Low Medium Low “Young” “Old” “middle-age” “Young” Parent I Parent II

slide-18
SLIDE 18

18

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

GA-Based Test Case Generation

  • Representation

– Each test case can be represented as a vector of binary or continuous values related to the inputs of the tested software

  • Initialization

– An initial test set can be generated randomly in the space of possible input values.

  • Genetic operators.

– Selection, crossover, and mutation operators can be adapted to representation of test cases for a specific program.

  • Evaluation function.

– Test cases can be evaluated by their fault-exposing-potential using buggy (mutated) versions of the original program.

slide-19
SLIDE 19

19

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Design of Experiments

  • Tested Algorithms:

– Simple GA [Goldberg]. – GA with varying population size (GAVaPS). – Crisp Age extension of GA. – Fuzzy-based Age extension of GA (three configurations).

80% 20%

FAexGA#3

75% 70%

FLC – “Old” lower limit

25% 30%

FLC – “Young” upper limit FAexGA#2 FAexGA#1 Parameter

slide-20
SLIDE 20

20

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Evaluation Measures

#runs yielding the optimal solution total number of runs

max

1 g u g = −

min max min

d d GD d d − = −

best

f PD f =

November 13, 2005 Shay Eyal 24

f = fitness f = fitness Phenotypical Phenotypical diversity diversity d= distance from the best solution d= distance from the best solution Genotypical diversity Genotypical diversity g = # of g = # of generations for the first solution generations for the first solution Unuse Unuse factor factor Solution Quality Solution Quality

Formula Formula Performance Performance measure measure

#runs yielding the optimal solution total number of runs

max

1 g u g = −

min max min

d d GD d d − = −

best

f PD f =

slide-21
SLIDE 21

21

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Case Study 1: Boolean Expression

  • Correct version - Boolean expression composed of 100

attributes and three logical operators: AND, OR, and NOT.

– This expression is generated randomly using an external application – Number of combinatorial test cases: 2100

  • Erroneous version - same Boolean expression as the correct
  • ne, except for a single error injected in the correct expression

by randomly selecting an OR operator and flipping it to the AND one (or vice versa).

  • GA parameters:

– Number of generations = 200. – Population size = 100. – Chromosome length = 100. – Crossover probability = 0.9 (for simple GA and GAVaPS). – Mutation probability = 0.01 – Discrete evaluation function (Error = Yes / No)

slide-22
SLIDE 22

22

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Boolean Expression Results

  • FAexGA#1 reached a solution in most of the runs with significant

differences compared to the others algorithms.

  • FAexGA#1 averaged the highest number of solutions (this should assist

locating the error).

  • FAexGA#1 averaged the highest Unuse factor

Measure\Algor ithm SimpleGA GAVaPS FAexGA#1 FAexGA#2 FAexGA#3 % Runs with solution 70% 60% 95% 70% 75% % Solutions in the final population 1.27% 81.52% 99.93% 98.86% 87.18% Unuse Factor 65.57% 62.27% 70.66% 68.71% 46.27%

slide-23
SLIDE 23

23

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Boolean Expression Results (cont.)

%Solutions

0.2 0.4 0.6 0.8 1 1.2 1 200 Generations % Solutions

SimpleGA GAVaPS FAex#1 FAex#2 FAex#3

slide-24
SLIDE 24

24

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Case Study 2: Credit Application

(Source: Last and Kandel, 2003)

  • Number of inputs: 8

– Five nominal and three continuous

  • Number of outputs: 2

– Decision (accept / reject) – Credit limit (continuous)

  • Physical lines of code: 63
  • Number of program flow paths: 52
  • Number of combinatorial tests: 11,312,000
slide-25
SLIDE 25

25

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Credit Application Results

Average of 10 runs

0.2 0.4 0.6 0.8 1 1 5 9 13 17 21 25 29 33 37 41 45 49 Generation #Solution/Total_Pop FAex#1

slide-26
SLIDE 26

26

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Summary

  • We have introduced a new, GA-based approach to generation of

effective black-box test cases

  • The Fuzzy-Based Age Extension of Genetic Algorithm (FAexGA)

appears to be much more efficient for this problem than the two other evaluated algorithms (SimpleGA and GAVaPS):

– FAexGA has a much higher probability to find an error in the tested software – The error would be found much faster, which should result in saving a lot

  • f resources for the testing team.

– In addition, the number of distinct solutions produced by FAexGA is significantly higher, which may be useful for investigation and identification of the error itself by the software programmers

  • Future research

– Experimentation with larger software programs – Development of more sophisticated, possibly continuous evaluation functions

slide-27
SLIDE 27

27

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Acknowledgments

  • This work was partially supported by the National

Institute for Systems Test and Productivity at University of South Florida under the USA Space and Naval Warfare Systems Command Grant No. N00039-01-1-2248 and by the Fulbright Foundation that has awarded Prof. Kandel the Fulbright Senior Specialists Grant at Ben-Gurion University of the Negev in November-December 2005.

slide-28
SLIDE 28

28

  • Dr. Mark Last (BGU)

Effective Black-Box Testing with Genetic Algorithms

Related Publications

  • Books

  • M. Last, A. Kandel, and H. Bunke (Editors), “Artificial Intelligence Methods in

Software Testing”. World Scientific, Series in Machine Perception and Artificial Intelligence, Vol. 56, 2004.

  • Papers

  • M. Last and A. Kandel, “Automated Test Reduction Using an Info-Fuzzy

Network”, T.M. Khoshgoftaar (Ed.), Software Engineering with Computational Intelligence, Kluwer Academic Publishers, pp. 235 – 258, 2003. –

  • M. Last, M. Friedman, and A. Kandel, “The Data Mining Approach to Automated

Software Testing", Proceedings of the Ninth ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD-2003), pp. 388 - 396, Washington, DC, USA August 24 - 27, 2003 –

  • M. Last, M. Friedman, and A. Kandel, “Using Data Mining for Automated

Software Testing", International Journal of Software Engineering and Knowledge Engineering (IJSEKE), Special Issue on Data Mining for Software Engineering and Knowledge Engineering, Vol. 14, No. 4, pp. 369-393, August 2004. –

  • M. Last and S. Eyal, A Fuzzy-Based Lifetime Extension of Genetic Algorithms,

Fuzzy Sets and Systems, Vol. 149, Issue 1, January 2005, 131-147.