White-Box Software Testing
using Evolutionary Algorithms
         Yaser Sulaiman




                                1
Time for a break!




                    2
Pex




      3
White-box testing




                    4
photo by Simon Goldenberg   5
Test adequacy criteria




                         6
Statement       Branch
   Weakest




   Strongest




  Path         Condition

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



                                 9
photo by racheocity   10
Cover as much as you can!




                            11
photo by [ d i e g o ]   12
Looks like an optimization
    problem.. sort of



                             13
So how about automating it?




                              14
Evolutionary algorithms




                          15
photo by ][/][   16
Genetic
 Algorithms
    (GA)




Evolutionary
 Algorithms




   Genetic
Programming
    (GP)


               17
GA




     18
Fitness
Selection
                 Function

       Chromosomes


Mutation        Crossover

                            19
GP




     20
Specialization of GA




                       21
Where individuals represent
  computer programs



                              22
GP evolves programs!




                       23
stolen from Wikipedia   24
Mathematically speaking




                          25
Given a set of inputs  and outputs
  , a program  is sought which
              satisfies

              = ()

                                  26
Fitness of a candidate program?




                              27
Expected output

                vs.

 = ()     Actual output

                                  28
2
  =            − 
          =1

  where  ∈  and  ∈ 



                                              29
Moving on to the surveyed papers




                              30
Brendt*   Tonella                Wappler*   Ahmed*
 2002      2004                   2006       2008




                    *   et al.                       31
Brendt*   Tonella                Wappler*   Ahmed*
 2002      2004                   2006       2008




                    *   et al.                       32
“Breeding software test cases with
       genetic algorithms”



                                33
“Breeding software test cases with
       genetic algorithms”



                                34
Fossil record




                35
Relative fitness function




                            36
Berndt et al. (2002)   37
3 factors affect the fitness function




                                   38
1. Novelty

measure of uniqueness



                        39
2. Proximity

measure of closeness



                       40
3. Severity

measure of seriousness



                         41
“simple rules, complex behavior”




                               42
Explorers, prospectors, and miners




                               43
Brendt*   Tonella                Wappler*   Ahmed*
 2002      2004                   2006       2008




                    *   et al.                       44
“Evolutionary testing of classes”




                                45
“Evolutionary testing of classes”




                                46
Object-oriented testing




                          47
Class Under Test (CUT)
           &
Method Under Test (MUT)



                          48
Sequence of object constructions &
          method calls



                                49
Tonella (2004) focuses on
representation and operators



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



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




                             52
Brendt*   Tonella                Wappler*   Ahmed*
 2002      2004                   2006       2008




                    *   et al.                       53
“Evolutionary unit testing of object-
 oriented software using strongly-
   typed genetic programming”



                                  54
“Evolutionary unit testing of object-
 oriented software using strongly-
   typed genetic programming”



                                  55
GP that is type-aware




                        56
Wappler & Wegener (2006) focus
  on call sequence feasibility



                            57
Wappler & Wegener (2006)   58
Method Call Dependence Graph
          (MCDG)



                           59
Wappler & Wegener (2006)   60
A sequence is feasible if it
corresponds to an acyclic subgraph
           of the MCDG



                                61
Wappler & Wegener (2006)   62
Brendt*   Tonella                Wappler*   Ahmed*
 2002      2004                   2006       2008




                    *   et al.                       63
“GA-based multiple paths test data
          generator”



                                64
“GA-based multiple paths test data
          generator”



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



                                   66
Generating multiple test data to
cover multiple target paths in one
             GA run



                                67
Requires incorporating the paths
 within the fitness calculation



                               68
// TODO: Redigest the paper.




                          69
Let’s compare the surveyed papers




                               70
Evolutionary        Object-   Coverage
  Paper
                  Algorithm         Oriented   Criterion

Berndt et al.
                       GA                       Branch
  (2002)
  Tonella
                       GA                       Branch
  (2004)
Wappler &
Wegener         Strongly-Typed GP               Branch
 (2006)
 Ahmed &
 Hermadi               GA                        Path
  (2008)


                                                           71
A direction for future work




                              72
The reverse direction




                        73
Evolutionary
Program                  Test Cases
           Algorithm




                                      74
Evolutionary
Program                  Test Cases
           Algorithm




                                      75
Writing test cases first?




                            76
It’s called TDD




                  77
photo by nyuhuhuu   78
photo by Magic Madzik   79
TDD + GP isn’t a new idea




                            80
81
Take-home messages




                     82
Generating test cases can be
       challenging



                               83
Testing object-oriented software
 provides even more challenges



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



                                 85
Even software developers turn to
 Mother Nature for inspiration



                               86
…</presentation>
  <questions>…



                   88

White-Box Software Testing using Evolutionary Algorithms