white-box software testing using evolutionary algorithms

86
White-Box Software Testing using Evolutionary Algorithms Yaser Sulaiman 1

Upload: yaser-sulaiman

Post on 05-Dec-2014

2.528 views

Category:

Technology


3 download

DESCRIPTION

A presentation I gave as part of our "Software Verification, Validation, and Quality Assurance" course at KFUPM.

TRANSCRIPT

Page 1: White-Box Software Testing using Evolutionary Algorithms

White-Box Software Testing using Evolutionary Algorithms

Yaser Sulaiman

1

Page 2: White-Box Software Testing using Evolutionary Algorithms

Time for a break!

2

Page 4: White-Box Software Testing using Evolutionary Algorithms

White-box testing

4

Page 5: White-Box Software Testing using Evolutionary Algorithms

5 photo by Simon Goldenberg

Page 6: White-Box Software Testing using Evolutionary Algorithms

Test adequacy criteria

6

Page 7: White-Box Software Testing using Evolutionary Algorithms

Statement

8

Branch

Condition Path

Weakest

Strongest

Page 8: White-Box Software Testing using Evolutionary Algorithms

Coming up with test cases/data isn’t as easy as it sounds

9

Page 10: White-Box Software Testing using Evolutionary Algorithms

Cover as much as you can!

11

Page 11: White-Box Software Testing using Evolutionary Algorithms

12 photo by [ d i e g o ]

Page 12: White-Box Software Testing using Evolutionary Algorithms

Looks like an optimization problem.. sort of

13

Page 13: White-Box Software Testing using Evolutionary Algorithms

So how about automating it?

14

Page 14: White-Box Software Testing using Evolutionary Algorithms

Evolutionary algorithms

15

Page 16: White-Box Software Testing using Evolutionary Algorithms

Evolutionary Algorithms

Genetic Algorithms

(GA)

Genetic Programming

(GP)

17

Page 17: White-Box Software Testing using Evolutionary Algorithms

GA

18

Page 18: White-Box Software Testing using Evolutionary Algorithms

Chromosomes

19

Selection Fitness

Function

Crossover Mutation

Page 19: White-Box Software Testing using Evolutionary Algorithms

GP

20

Page 20: White-Box Software Testing using Evolutionary Algorithms

Specialization of GA

21

Page 21: White-Box Software Testing using Evolutionary Algorithms

Where individuals represent computer programs

22

Page 22: White-Box Software Testing using Evolutionary Algorithms

GP evolves programs!

23

Page 23: White-Box Software Testing using Evolutionary Algorithms

24 stolen from Wikipedia

Page 24: White-Box Software Testing using Evolutionary Algorithms

Mathematically speaking

25

Page 25: White-Box Software Testing using Evolutionary Algorithms

Given a set of inputs 𝑋 and outputs 𝑌, a program 𝑝 is sought which

satisfies

𝑌 = 𝑝(𝑋)

26

Page 26: White-Box Software Testing using Evolutionary Algorithms

Fitness of a candidate program?

27

Page 27: White-Box Software Testing using Evolutionary Algorithms

𝑌𝑒𝑥𝑝 Expected output

vs.

𝑌𝑝 = 𝑝(𝑋) Actual output

28

Page 28: White-Box Software Testing using Evolutionary Algorithms

𝑓 𝑝 = 𝑝 𝑥𝑖 − 𝑦𝑒𝑥𝑝𝑖2

𝑋

𝑖=1

where 𝑥 ∈ 𝑋 and 𝑦𝑒𝑥𝑝 ∈ 𝑌𝑒𝑥𝑝

29

Page 29: White-Box Software Testing using Evolutionary Algorithms

Moving on to the surveyed papers

30

Page 30: White-Box Software Testing using Evolutionary Algorithms

Brendt* 2002

Tonella 2004

Wappler* 2006

Ahmed* 2008

31 * et al.

Page 31: White-Box Software Testing using Evolutionary Algorithms

Brendt* 2002

Tonella 2004

Wappler* 2006

Ahmed* 2008

32 * et al.

Page 32: White-Box Software Testing using Evolutionary Algorithms

“Breeding software test cases with genetic algorithms”

33

Page 33: White-Box Software Testing using Evolutionary Algorithms

“Breeding software test cases with genetic algorithms”

34

Page 34: White-Box Software Testing using Evolutionary Algorithms

Fossil record

35

Page 35: White-Box Software Testing using Evolutionary Algorithms

Relative fitness function

36

Page 36: White-Box Software Testing using Evolutionary Algorithms

37 Berndt et al. (2002)

Page 37: White-Box Software Testing using Evolutionary Algorithms

3 factors affect the fitness function

38

Page 38: White-Box Software Testing using Evolutionary Algorithms

1. Novelty

measure of uniqueness

39

Page 39: White-Box Software Testing using Evolutionary Algorithms

2. Proximity

measure of closeness

40

Page 40: White-Box Software Testing using Evolutionary Algorithms

3. Severity

measure of seriousness

41

Page 41: White-Box Software Testing using Evolutionary Algorithms

“simple rules, complex behavior”

42

Page 42: White-Box Software Testing using Evolutionary Algorithms

Explorers, prospectors, and miners

43

Page 43: White-Box Software Testing using Evolutionary Algorithms

Brendt* 2002

Tonella 2004

Wappler* 2006

Ahmed* 2008

44 * et al.

Page 44: White-Box Software Testing using Evolutionary Algorithms

“Evolutionary testing of classes”

45

Page 45: White-Box Software Testing using Evolutionary Algorithms

“Evolutionary testing of classes”

46

Page 46: White-Box Software Testing using Evolutionary Algorithms

Object-oriented testing

47

Page 47: White-Box Software Testing using Evolutionary Algorithms

Class Under Test (CUT) &

Method Under Test (MUT)

48

Page 48: White-Box Software Testing using Evolutionary Algorithms

Sequence of object constructions & method calls

49

Page 49: White-Box Software Testing using Evolutionary Algorithms

Tonella (2004) focuses on representation and operators

50

Page 50: White-Box Software Testing using Evolutionary Algorithms

A chromosome isn’t just a sequence of input values anymore

51

Page 51: White-Box Software Testing using Evolutionary Algorithms

$a=A():$b=B():$a.m(int, $b) @ 3

52

Page 52: White-Box Software Testing using Evolutionary Algorithms

Brendt* 2002

Tonella 2004

Wappler* 2006

Ahmed* 2008

53 * et al.

Page 53: White-Box Software Testing using Evolutionary Algorithms

“Evolutionary unit testing of object-oriented software using strongly-

typed genetic programming”

54

Page 54: White-Box Software Testing using Evolutionary Algorithms

“Evolutionary unit testing of object-oriented software using strongly-

typed genetic programming”

55

Page 55: White-Box Software Testing using Evolutionary Algorithms

GP that is type-aware

56

Page 56: White-Box Software Testing using Evolutionary Algorithms

Wappler & Wegener (2006) focus on call sequence feasibility

57

Page 57: White-Box Software Testing using Evolutionary Algorithms

58 Wappler & Wegener (2006)

Page 58: White-Box Software Testing using Evolutionary Algorithms

Method Call Dependence Graph (MCDG)

59

Page 59: White-Box Software Testing using Evolutionary Algorithms

60 Wappler & Wegener (2006)

Page 60: White-Box Software Testing using Evolutionary Algorithms

A sequence is feasible if it corresponds to an acyclic subgraph

of the MCDG

61

Page 61: White-Box Software Testing using Evolutionary Algorithms

62 Wappler & Wegener (2006)

Page 62: White-Box Software Testing using Evolutionary Algorithms

Brendt* 2002

Tonella 2004

Wappler* 2006

Ahmed* 2008

63 * et al.

Page 63: White-Box Software Testing using Evolutionary Algorithms

“GA-based multiple paths test data generator”

64

Page 64: White-Box Software Testing using Evolutionary Algorithms

“GA-based multiple paths test data generator”

65

Page 65: White-Box Software Testing using Evolutionary Algorithms

Ahmed & Hermadi (2008) focus on the efficiency of test data generation

66

Page 66: White-Box Software Testing using Evolutionary Algorithms

Generating multiple test data to cover multiple target paths in one

GA run

67

Page 67: White-Box Software Testing using Evolutionary Algorithms

Requires incorporating the paths within the fitness calculation

68

Page 68: White-Box Software Testing using Evolutionary Algorithms

// TODO: Redigest the paper.

69

Page 69: White-Box Software Testing using Evolutionary Algorithms

Let’s compare the surveyed papers

70

Page 70: White-Box Software Testing using Evolutionary Algorithms

71

Paper Evolutionary

Algorithm Object-

Oriented Coverage Criterion

Berndt et al. (2002)

GA Branch

Tonella (2004)

GA Branch

Wappler & Wegener (2006)

Strongly-Typed GP Branch

Ahmed & Hermadi (2008)

GA Path

Page 71: White-Box Software Testing using Evolutionary Algorithms

A direction for future work

72

Page 72: White-Box Software Testing using Evolutionary Algorithms

The reverse direction

73

Page 73: White-Box Software Testing using Evolutionary Algorithms

74

Program Evolutionary

Algorithm Test Cases

Page 74: White-Box Software Testing using Evolutionary Algorithms

75

Program Evolutionary

Algorithm Test Cases

Page 75: White-Box Software Testing using Evolutionary Algorithms

Writing test cases first?

76

Page 76: White-Box Software Testing using Evolutionary Algorithms

It’s called TDD

77

Page 78: White-Box Software Testing using Evolutionary Algorithms

79 photo by Magic Madzik

Page 79: White-Box Software Testing using Evolutionary Algorithms

TDD + GP isn’t a new idea

80

Page 81: White-Box Software Testing using Evolutionary Algorithms

Take-home messages

82

Page 82: White-Box Software Testing using Evolutionary Algorithms

Generating test cases can be challenging

83

Page 83: White-Box Software Testing using Evolutionary Algorithms

Testing object-oriented software provides even more challenges

84

Page 84: White-Box Software Testing using Evolutionary Algorithms

Evolutionary algorithms can be used to solve [some of] these

problems

85

Page 85: White-Box Software Testing using Evolutionary Algorithms

Even software developers turn to Mother Nature for inspiration

86

Page 86: White-Box Software Testing using Evolutionary Algorithms

…</presentation> <questions>…

88