SlideShare a Scribd company logo
1 of 156
Download to read offline
Model-Based Testing




                                     Harry Robinson
                                     Google
                                     harryr@google.com
     © 2006 Harry Robinson, Google
Goals for Today
• Convey techniques for
    • How to model systems
    • How to generate tests
    • How to verify results

• Communicate a mindset
• Provide inspiration
• Foster discontent
                © 2006 Harry Robinson, Google
Non-Goals for Today


• Specific tools

• Interfacing with an application




              © 2006 Harry Robinson, Google
What are the Problems of
  Software Testing?

     • Time is limited



     • Applications are complex


     • Requirements are fluid

       © 2006 Harry Robinson, Google
What’s wrong with manual
        testing?




       © 2006 Harry Robinson, Google
Manual testing is ok sometimes …



            Start        Digital                    Stop


Clock.exe                                                  Clock.exe




                    © 2006 Harry Robinson, Google
… but it can rarely go deep enough

                    ?
                    ?                              ?
                                                   ?
                    Analog                              Digital

            Start            Digital                          Stop


Clock.exe                                                            Clock.exe



                    DblClk                              DblClk


                    ?
                    ?                              ?
                                                   ?
                        © 2006 Harry Robinson, Google
What’s wrong with scripting?




          © 2006 Harry Robinson, Google
The Villain of this Piece
                   CurrentWindow = WFndWndC("Calculator", "SciCalc")
                   WSetWndPosSiz(CurrentWindow, 88, 116, 260, 260)
                   WMenuSelect("@2@2")
                   CurrentWindow = WFndWndC("Calculator", "SciCalc")
                   WSetWndPosSiz(CurrentWindow, 88, 116, 480, 317)
                   WButtonClick("@32")
                   WButtonClick("@27")
                   WButtonClick("@38")
                   WButtonClick("@58")
                   WMenuSelect("@2@1")
                   CurrentWindow = WFndWndC("Calculator", "SciCalc")
                   WSetWndPosSiz(CurrentWindow, 88, 116, 260, 260)
                   WMenuSelect("@2@1")
                   Play "{Click 330, 131, Left}"
                   WToolbarButtonClk("@2", "@6")
• Awe-inspiring    WToolbarButtonClk("@2", "@7")
                   WToolbarButtonClk("@1", "@1")


• Unchanging

• Indecipherable
                   © 2006 Harry Robinson, Google
Scripts are ok for some uses …

Test case 1: Start Digital Stop Start Analog Stop
Test case 2: Start DblClk Stop Start DblClk Stop




                             © 2006 Harry Robinson, Google
… but they pile up quickly …

Test case 1: Start Digital Stop Start Analog Stop
Test case 2: Start DblClk Stop Start DblClk Stop
Test case 3: Start Digital DblClk Stop Start DblClk Analog Stop
Test case 4: Start DblClk DblClk Digital DblClk DblClk Stop Start Analog Stop
Test case 5: …




                            © 2006 Harry Robinson, Google
… and what are you left with?

Test case 1: Start Digital Stop Start Analog Stop
Test case 2: Start DblClk Stop Start DblClk Stop
Test case 3: Start Digital DblClk Stop Start DblClk Analog Stop
Test case 4: Start DblClk DblClk Digital DblClk DblClk Stop Start Analog Stop
Test case 5: Start Digital Digital Stop Start Analog Stop
Test case 6: Start DblClk Stop Start Analog DblClk Stop
Test case 7: Start Digital DblClk Stop Start Digital DblClk Analog Stop
Test case 8: Start DblClk DblClk Digital Analog DblClk DblClk Stop
Test case 9: …




                            © 2006 Harry Robinson, Google
What is a model?



• A model is a description of a system.

• Models are simpler than the systems they describe.

• Models help us understand and predict the system’s behavior.



                        © 2006 Harry Robinson, Google
What is model-based testing?
“Model-based testing is a testing technique where the
runtime behavior of an implementation under test is
checked against predictions made by a formal
specification, or model.” - Colin Campbell, MSR
                     In other words
• A model describes how a system should behave in
response to an action.
• Supply the action and see if the system responds as
you expect.

                     © 2006 Harry Robinson, Google
Traditional Automated Testing




Imagine that this projector is the software you are testing.

                    © 2006 Harry Robinson, Google
Traditional Automated Testing




Typically, testers automate by creating static scripts.

                 © 2006 Harry Robinson, Google
Traditional Automated Testing




Given enough time, these scripts will cover the behavior.

                   © 2006 Harry Robinson, Google
Traditional Automated Testing




But what happens when the software’s behavior changes?

                © 2006 Harry Robinson, Google
So What’s a Model?




• A model is a description of a system’s behavior.

• Models are simpler than the systems they describe.

• Models help us understand and predict the system’s behavior.



                       © 2006 Harry Robinson, Google
Model-Based Testing




Now, imagine that the top projector is your model.

                © 2006 Harry Robinson, Google
Model-Based Testing




The model generates tests to cover the behavior.

               © 2006 Harry Robinson, Google
Model-Based Testing




… and when the behavior changes…

        © 2006 Harry Robinson, Google
Model-Based Testing




… so do the tests.

           © 2006 Harry Robinson, Google
Using Models to Test


• What type of model do I use?
• How do I create the model?
• How do I choose tests?
• How do I verify results?


          © 2006 Harry Robinson, Google
Many Types of Models
 • States
 • Monkeys
 • Sets
 • Grammars
 • Combinations
 • Other
          © 2006 Harry Robinson, Google
Creating a Model




    © 2006 Harry Robinson, Google
We All Use Mental Models Already


                   Digital




                  hmm …

             if I am in the Analog display

             and I execute the Digital action

             I should end up in the Digital display




           © 2006 Harry Robinson, Google
State Table Representation


   Analog           Digital
                                            Digital


 StartState      Action                     EndState
 Analog          Digital                    Digital




            © 2006 Harry Robinson, Google
Exercise 1

     Modeling a Website




Based on “Model-Based Testing: Not for Dummies” by Jeff Feldstein
                   © 2006 Harry Robinson, Google
State Table Representation




 StartState       Action                      EndState
 HomePage         ImageTab                    ImagePage
 HomePage         NewsTab                     NewsPage
 ImagePage        HomeTab                     HomePage
 ImagePage        NewsTab                     NewsPage
 NewsPage         HomeTab                     HomePage
 NewsPage         ImageTab                    ImagePage
              © 2006 Harry Robinson, Google
Exercise 2



Modeling Notepad




    © 2006 Harry Robinson, Google
Notepad Model

                     Type A
                                               Close
Start

                                              Cancel
    Close            Delete A


                           No




              © 2006 Harry Robinson, Google
Notepad State Table
StartState          Action                    EndState
NotRunning          Start                     MainWindow
WindowEmpty         TypeA                     WindowDirty
WindowEmpty         Close                     NotRunning
WindowDirty         Delete                    WindowEmpty
WindowDirty         Close                     SaveDialog
SaveDialog          Cancel                    WindowDirty
SaveDialog          No                        NotRunning


              © 2006 Harry Robinson, Google
Exercise 3



Modeling Wordpad




    © 2006 Harry Robinson, Google
Wordpad Model
                                   Delete A

                                              Close
                                    Type A
            Type A                            Cancel
Start                                Close

   Close                            Cancel
             No



                         No




              © 2006 Harry Robinson, Google
Wordpad State Table
StartState            Action                   EndState
NotRunning            Start                    MainWindow
WindowEmpty1          TypeA                    WindowDirty
WindowEmpty1          Close                    NotRunning
WindowDirty           Delete                   WindowEmpty2
WindowDirty           Close                    SaveDialog1
WindowEmpty2          TypeA                    WindowDirty
WindowEmpty2          Cancel                   SaveDialog2
SaveDialog1           Cancel                   WindowDirty
SaveDialog1           No                       NotRunning
SaveDialog2           Cancel                   WindowEmpty2
SaveDialog2           No                       NotRunning
               © 2006 Harry Robinson, Google
Exercise 4



Modeling Clock using Rules

                Digital




        © 2006 Harry Robinson, Google
Modeling Clock States
In our discussion of the Clock behavior, we only
   tracked a few data values in the application:


                                                   Running
                 was described as                   Digital
                                                   Framed



                                                    Running
                 was described as                   Analog
                                                   Unframed



                   © 2006 Harry Robinson, Google
Modeling Clock Actions
We also tracked how our actions change those values:

                                            Running
                                            Analog
                                            Framed

               Digital                             Digital



                                            Running
                                            Digital
                                            Framed


                   © 2006 Harry Robinson, Google
So, we can replace this model …

                    Analog                                    Digital
            Start                Digital                            Stop


Clock.exe   Stop                   Analog                               Start   Clock.exe



                    DblClk   DblClk         DblClk            DblClk


            Start                                                   Stop


Clock.exe   Stop                                                    Start       Clock.exe




                              © 2006 Harry Robinson, Google
… with a state variable model

                   Analog                                             Digital
           Start                         Digital                            Stop
Stopped                     Running                         Running                     Stopped
 Analog                     Analog                           Digital                     Digital
Framed                      Framed                          Framed                      Framed
           Stop                            Analog                               Start


                   DblClk        DblClk             DblClk            DblClk


 Stopped
           Start         Running                           Running
                                                                            Stop         Stopped
  Analog                 Analog                             Digital                       Digital
Unframed                Unframed                          Unframed                      Unframed
           Stop                                                             Start


                                      © 2006 Harry Robinson, Google
Rules for the Stop action

• If the Clock is Running, then the user can
  execute the ‘Stop’ action.
• The ‘Stop’ action puts you in Stopped mode

 static void Stop( )
 requires (AppStatus == AppValues.Running);            Stop

 {
    AppStatus = AppValues.Stopped;
 }
                                                  Clock.exe




                  © 2006 Harry Robinson, Google
Rules for the SelectDigital action
• If the Clock is Running and Framed, then the user
  can execute the ‘SelectDigital’ action
• The ‘SelectDigital’ action puts you in Digital mode



 static void SelectDigital( )
 requires (AppStatus == AppValues.Running)           Select
  && (FrameStatus == FrameValues.Framed);            Digital
 {
   ModeStatus = ModeValues.Digital;
 }

                     © 2006 Harry Robinson, Google
A generated state table!
STARTSTATE                        ACTION                   ENDSTATE
Stopped Analog Framed            Start                     Running Analog Framed
Running Analog Framed            Stop                      Stopped Analog Framed
Running Analog Framed            SelectAnalog              Running Analog Framed
Running Analog Framed            SelectDigital             Running Digital Framed
Running Analog Framed            DblClk                    Running Analog Unframed
Running Digital Framed           Stop                      Stopped Digital Framed
Running Digital Framed           SelectAnalog              Running Analog Framed
Running Digital Framed           SelectDigital             Running Digital Framed
Running Digital Framed           DblClk                    Running Digital Unframed
Running Analog Unframed          Stop                      Stopped Analog Unframed
Running Analog Unframed          DblClk                    Running Analog Framed
Stopped Digital Framed           Start                     Running Digital Framed
Running Digital Unframed         Stop                      Stopped Digital Unframed
Running Digital Unframed         DblClk                    Running Digital Framed
Stopped Analog Unframed          Start                     Running Analog Unframed
Stopped Digital Unframed         Start                     Running Digital Unframed


                           © 2006 Harry Robinson, Google
A state diagram




   © 2006 Harry Robinson, Google
Generating Tests from a Model




          © 2006 Harry Robinson, Google
Generating Test Sequences
We can use the machine-readable model to create test sequences:


•   Random walk
•   All transitions
•   Shortest paths first
•   Most likely paths first




                       © 2006 Harry Robinson, Google
A Random Walk




  © 2006 Harry Robinson, Google
A sequence that hits all transitions




            © 2006 Harry Robinson, Google
An all-transitions sequence

  1.   Start                    9. Start
  2.   Analog                   10. Double Click
  3.   Digital                  11. Analog
  4.   Digital                  12. Double Click
  5.   Stop                     13. Stop
  6.   Start                    14. Start
  7.   Double Click             15. Double Click
  8.   Stop                     16. Stop



                © 2006 Harry Robinson, Google
All paths of length 2




      © 2006 Harry Robinson, Google
All paths of length 3




      © 2006 Harry Robinson, Google
All paths of length 4




      © 2006 Harry Robinson, Google
All paths of length < 5

1. Start, Stop
2. Start, Analog, Stop
3. Start, Analog, Analog, Stop
4. Start, Digital, Analog, Stop
5. Start, Double Click, Double Click, Stop




                    © 2006 Harry Robinson, Google
Exercise 5


Brainstorming Traversals




        © 2006 Harry Robinson, Google
How would you test this?




        © 2006 Harry Robinson, Google
Pathological




 © 2006 Harry Robinson, Google
Closer in …




 © 2006 Harry Robinson, Google
Partial state table for the maze
 *west end of long hall                  South       maze of twisty little passages

 maze of twisty little passages          Up          twisty little maze of passages

 maze of twisty little passages          NW          twisty maze of little passages

 maze of twisty little passages          North       maze of little twisty passages

 maze of twisty little passages          NE          twisting maze of little passages

 maze of twisty little passages          West        maze of little twisting passages

 maze of twisty little passages          East        little twisty maze of passages

 maze of twisty little passages          SW          little maze of twisty passages


                             © 2006 Harry Robinson, Google
Executing the Test Actions
1.   Start
2.   Analog
3.   Digital
4.   Digital
5.   Stop
6.   Start
7.   Double Click
8.   Stop



                    © 2006 Harry Robinson, Google
Exercise 6



Modeling from a Spec




      © 2006 Harry Robinson, Google
“Accessing an Account”

1. customer needs to log in to use the system
2. customer stays logged in to the system until she logs out
3. customer starts with no account
4. customer can create an account
5. customer can delete her account
6. customer can open an existing account
7. customer can close an existing account


                      © 2006 Harry Robinson, Google
Verifying the Outcomes




       © 2006 Harry Robinson, Google
Oracles
•   Crashes
•   Prediction
•   Checking
•   Pre-oracling
•   Heuristics
•   Filtering + Humans
•   Assertions
                © 2006 Harry Robinson, Google
Exercise 7



Monkeying an Input Field




   Inspired by Noel Nyman’s article “Using Monkey Test Tools”
              © 2006 Harry Robinson, Google
Monkey Models

       Nothing I do                     1.2
should make this app crash…             a P, a P, ab P, ab P 2, abc P, P, P, P,
                                        scbuild1
                                        Type 5
                                        containing message laurie Bill's October
                                        ?A
                                        ? v?-0Qrg+ 'cQ?_<$ ` Z`i7c} oV? E1X …
                                        nov 31, 2000 Oct, 2000 dates Wednesday …
                                        alike. In Word documents, for example …
                                        3 M note
                                        RNL in Office 10




                              © 2006 Harry Robinson, Google
Predicting the Outcome

StartState     Action                    EndState
Analog         Digital                   Digital




         © 2006 Harry Robinson, Google
Exercise 8


Oracling the Square Root Function




           © 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
Exercise 9


Oracling the Sine Function




              Academy Artworks




    Inspired by Doug Hoffman’s article “Heuristic Test Oracles”

                 © 2006 Harry Robinson, Google
sin 2(x)   +     cos 2(x)             =1

  cos(x) = sin(x-pi)


sin2(x) + sin2(x-pi) = 1

       © 2006 Harry Robinson, Google
Modeling with Sets




     © 2006 Harry Robinson, Google
Exercise 10



Modeling Search




   © 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
+ruby             +ruby                       -ruby
             -pragmatic         +pragmatic                 +pragmatic
              3143 files          12 files                   70 files




  +ruby                                                                 +pragmatic
3513 files                                                                82 files

                           © 2006 Harry Robinson, Google
3513 – 12 = ?


                +ruby             +ruby                       -ruby
             -pragmatic         +pragmatic                 +pragmatic
              3143 files          12 files                   70 files




  +ruby                                                                 +pragmatic
3513 files                                                                82 files

                           © 2006 Harry Robinson, Google
Modeling with Grammars
       Expr ::= IDENT
         | NUMBER
         | "let" Ident = Expr "in" Expr
         | Expr + Expr
         | Expr - Expr




         © 2006 Harry Robinson, Google
How a Production Grammar Works




          © 2006 Harry Robinson, Google
Exercise 11



Modeling HTML




  © 2006 Harry Robinson, Google
A mini-html grammar
{seed}:=<html>{body}</html>;

{body}:={body}<P>{body}|<H1>{body2}</H1>|<H4>{body2}</H4>;

{body2}:=<font color="red"> {body3} </font>|<font color="blue"> {body3} </font>;

{body3}:=<U>{body4}</U>|{body4};

{body4}:=<I> {body5} </I> | {body5};

{body5}:=the quick brown fox;




                               © 2006 Harry Robinson, Google
Grammar Example 1



Modeling Arithmetic Expressions


 100 * 5 / (6 – 5.01 * 3.14159)


  Inspired by Pete TerMaat’s article “Adventures in Automated Testing”

                       © 2006 Harry Robinson, Google
Evaluate the following expressions

1.   10 * 1.0 * 0.1 * 6.0 * 1.16666666667 * 1.0 * 1.14285714286 * 5.25

2.   2 * 2.5 * 0.4 * 4.0 * 1.25 * 1.0 * 0.8 * 5.25

3.   4 * 0.5 * 3.5 * 1.0 * 0.285714285714 * 3.0 * 0.166666666667 * 42.0

4.   2 * 5.0 * 0.2 * 1.5 * 1.0 * 2.66666666667 * 1.125 * 4.66666666667

5.   5 * 1.6 * 1.0 * 0.5 * 1.75 * 0.428571428571 * 0.333333333333 * 42.0

6.   4 * 2.0 * 0.75 * 1.5 * 0.444444444444 * 0.75 * 2.66666666667 * 5.25

7.   6 * 1.5 * 0.777777777778 * 0.428571428571 * 1.33333333333 * 0.25 * 7.0 * 6.0

8.   2 * 1.5 * 0.333333333333 * 10.0 * 0.5 * 0.8 * 1.5 * 7.0

9.   5 * 0.6 * 1.66666666667 * 0.2 * 1.0 * 1.0 * 10.0 * 4.2




                                © 2006 Harry Robinson, Google
42
                         5 * 8.4

                     5 * 1.0 * 8.4

                  1 * 5.0 * 1.0 * 8.4

               1 * 1.0 * 5.0 * 1.0 * 8.4

            10 * 0.1 * 1.0 * 5.0 * 1.0 * 8.4

         8 * 1.25 * 0.1 * 1.0 * 5.0 * 1.0 * 8.4

7 * 1.14285714286 * 1.25 * 0.1 * 1.0 * 5.0 * 1.0 * 8.4



               © 2006 Harry Robinson, Google
Evaluate the following expression

 10 * 0.6 * 1.5 * 0.666666666667 * 1.0 * 1.0 * 0.833333333333 * 1.2 * 1.5 * 0.666666666667 *

 1.33333333333 * 0.375 * 1.66666666667 * 1.0 * 2.0 * 1.0 * 0.9 * 0.777777777778 * 1.0 *

 0.428571428571 * 3.0 * 0.666666666667 * 1.5 * 0.222222222222 * 0.5 * 5.0 * 2.0 * 0.4 * 2.0 *

 0.5 * 0.75 * 1.33333333333 * 0.75 * 2.33333333333 * 1.42857142857 * 0.7 * 1.0 *

 1.28571428571 * 1.0 * 0.333333333333 * 2.0 * 0.833333333333 * 0.2 * 6.0 * 1.33333333333 *

 0.375 * 0.666666666667 * 1.0 * 2.0 * 2.25 * 0.222222222222 * 4.5 * 0.888888888889 * 0.125

 * 4.0 * 2.0 * 0.75 * 1.0 * 1.5 * 0.333333333333 * 2.33333333333 * 0.428571428571 * 3.0 *

 0.888888888889 * 0.625 * 0.2 * 8.0 * 0.375 * 0.333333333333 * 7.0 * 1.42857142857 * 0.1 *

 3.0 * 3.33333333333 * 1.0 * 0.6 * 0.333333333333 * 4.0 * 0.5 * 2.5 * 0.5 * 1.4 *

 1.14285714286 * 0.25 * 0.5 * 7.0 * 0.428571428571 * 2.0 * 1.0 * 0.5 * 0.666666666667 * 4.5 *

 0.333333333333 * 2.33333333333 * 0.571428571429 * 1.75 * 0.428571428571 * 2.0 * 0.5 *

 14.0




                             © 2006 Harry Robinson, Google
Grammar Example 2



Modeling C Code
   static void TestCase(){
   while( Fun("L21") ){
   L22: break; }}
   else {
   L3:{
   L31:      goto L22;
   L32:      goto L31; }}


   © 2006 Harry Robinson, Google
Grammar Model for a Subset of C
Statement :: if ( BooleanCondition ) { Statement } else { Statement }
Statement :: while ( BooleanCondition ) { Statement }
Statement :: { Statement Statement }
Statement :: break;
Statement :: goto Label;
Statement :: Label : Statement
Statement :: ExpressionStatement;
ExpressionStatement :: MethodCall
BooleanExpression :: MethodCall
MethodCall :: Fun(Label)



 Based on “A High-Level Modular Definition of the Semantics of C#”
                                          - Boerger, Fruja, Gervasi, Stark

                          © 2006 Harry Robinson, Google
Deriving Programs from the Grammar
                            { Statement }


         { if ( Boolean ) { Statement } else { Statement } }


       { if ( MethodCall ) { Statement } else { Statement } }


 { if ( MethodCall ) { Statement Statement } else { Statement } }




                        © 2006 Harry Robinson, Google
Tests Generated from the Grammar
        suite123.cs                                        suite321.cs
static void TestCase(){                        static void TestCase(){
L:                                             L:
if ( Fun("L1") ){                              if ( Fun("L1") ){
L2:                                            L2:
if ( Fun("L21") ){                             while( Fun("L21") ){
L22: goto L;                                   L22:
}                                              break;
else{                                          }}
L23: goto L;                                   else{
}}                                             L3:
else{                                          {
L3:                                            L31: goto L;
{                                              L32: goto L31;
L31: goto L32;                                 }}}
L32: goto L;
}}}


      “Experiments on Semantics Based Testing of a Compiler” - Esin, Novikov, Yavorskiy
                           © 2006 Harry Robinson, Google
Exercise 12



Modeling Combinations




      © 2006 Harry Robinson, Google
Exercise 13


       Selecting Sandwiches




Inspired by an example in Lou Tylee’s book “Visual C# Express for Kids”

                        © 2006 Harry Robinson, Google
Setting Up the Combinations

Bread    Cheese H        MU      MA      L           T
white    none     ham    mustard mayo    lettuce     tomato
wheat    american no_ham no_must no_mayo no_lett     no_tom
rye      swiss




        Using James Bach’s AllPairs program from www.satisfice.com

                     © 2006 Harry Robinson, Google
Generating the Pairs
TEST CASES
case   Bread   Cheese     H        M           MA        L         T
1      white   none       ham      mustard     mayo      lettuce   tomato
2      white   american   no_ham   no_must     no_mayo   no_lett   no_tom
3      wheat   none       no_ham   mustard     no_mayo   lettuce   no_tom
4      wheat   american   ham      no_must     mayo      no_lett   tomato
5      rye     swiss      ham      mustard     no_mayo   no_lett   tomato
6      rye     swiss      no_ham   no_must     mayo      lettuce   no_tom
7      white   none       ham      no_must     no_mayo   no_lett   no_tom
8      white   american   no_ham   mustard     mayo      lettuce   tomato
9      wheat   swiss      ham      mustard     mayo      no_lett   no_tom
10     rye     none       no_ham   no_must     no_mayo   lettuce   tomato
11     rye     american   ham      mustard     no_mayo   lettuce   no_tom
12     white   swiss      no_ham   no_must     no_mayo   no_lett   tomato



                     © 2006 Harry Robinson, Google
But, did we miss any behavior of interest?




               © 2006 Harry Robinson, Google
Exercise 14



         Modeling the Triangle




Inspired by B J Rollison’s conference paper “Dissecting the Triangle Problem”

                          © 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
Exhaustion?
for ( a=0; a<=32767; a++)
  for ( b=0; b<=32767; b++)
      for ( c=0; c<=32767; c++)
            evaluate( a, b, c);




               © 2006 Harry Robinson, Google
Exercise 15

Modeling Google Maps




      © 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
0.60 miles

             © 2006 Harry Robinson, Google
Trip #115
Trip start: 47.7945, -122.493
Trip end: 47.74753 -122.36585


Google route distance is 102.0 miles
Straightline distance is 6.7 miles


Ratio is 15.2 --------------------- SUSPICIOUS...



                        © 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
Checking Driving Directions




               © 2006 Harry Robinson, Google
Checking Driving Directions




               © 2006 Harry Robinson, Google
The Long Road Home




             © 2006 Harry Robinson, Google
What Kinds of Bugs do
   Models Find?




      © 2006 Harry Robinson, Google
The Incredible Shrinking Clock

    Start
    Maximize
    Stop
    Start
    Minimize
    Stop


!   Start
    Restore
    Stop



               © 2006 Harry Robinson, Google
That Was the Year that Wasn’t
Start
Minimize
Stop
Start
Restore
Date


        !
                 © 2006 Harry Robinson, Google
What Kinds of Bugs do
 Models NOT Find?




      © 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
© 2006 Harry Robinson, Google
Where is
    Model-Based Testing
         Heading?

1. Security Testing
2. Shortening Bug Repro Scenarios
3. Meaningful Regression Testing

4. Machine Learning?




               © 2006 Harry Robinson, Google
Security Testing

“The testing method developed in the PROTOS project is uniquely practical
    .... Tests are conducted by bombing software with illegally formatted or
    unexpected input.”
                               Tekes - National Technology Agency of Finland



CERT Advisories
•   CA-2001-18   Multiple   Vulnerabilities         in   LDAP Implementations
•   CA-2002-03   Multiple   Vulnerabilities         in   SNMP Implementations
•   CA-2003-06   Multiple   Vulnerabilities         in   SIP Implementations
•   CA-2003-11   Multiple   Vulnerabilities         in   Lotus Notes and Domino




                             © 2006 Harry Robinson, Google
Shortening Repro Scenarios




        © 2006 Harry Robinson, Google
The Motivation
“The fewer steps that it takes to reproduce a bug,
the fewer places the programmer has to look (usually).

If you make it easier to find the cause and test the change,
you reduce the effort required to fix the problem.
Easy bugs gets fixed even if they are minor.“

                       - from Testing Computer Software




                     © 2006 Harry Robinson, Google
The Beeline Approach

A repro path is simply another traversal through the
state model, so …

      1.   Choose any 2 nodes in the repro path

      2. Find the shortest path between them

      3. Execute the spliced ‘shortcut’ path

      4. Evaluate the results and repeat



                    © 2006 Harry Robinson, Google
The repro path reduction problem
      1




      2




                                3



           © 2006 Harry Robinson, Google
Random walk finds a bug
       1




       2




                                    3

… but the repro path is inconveniently long
               © 2006 Harry Robinson, Google
1. Choose any 2 nodes in the path
       1




       2




                                 3



            © 2006 Harry Robinson, Google
2. Find shortest path between them
       1




       2




                                 3



            © 2006 Harry Robinson, Google
3. Execute the spliced shortcut path
            1




            2




                                         3

   The bug repro’ed - this is the new shortest path
                    © 2006 Harry Robinson, Google
Continue trimming …
1

    A

2

               B

                             3



        © 2006 Harry Robinson, Google
… until you stop.
1




2




                            3



       © 2006 Harry Robinson, Google
Why Use a Model for Reducing?

• The model can detect (and therefore reduce) both
  crashing AND non-crashing bugs.
• Finding a shortcut is simple in a model, so the
  reduction is more efficient.
• Finding bugs is good. Getting them fixed is better.




                    © 2006 Harry Robinson, Google
That Was The Year That Wasn’t


Start
Minimize
Stop
Start
Restore
Date




            © 2006 Harry Robinson, Google
An 84-step repro sequence

invoke about ok_about no_title doubleclick seconds restore
seconds doubleclick doubleclick date about ok_about restore
gmt maximize doubleclick doubleclick date seconds date
close_clock invoke close_clock invoke close_clock invoke
seconds date restore about ok_about no_title doubleclick
digital doubleclick doubleclick no_title doubleclick no_title
doubleclick seconds restore restore doubleclick doubleclick gmt
analog maximize date digital minimize restore minimize
close_clock invoke restore digital date minimize close_clock
invoke maximize gmt digital restore doubleclick doubleclick
about ok_about maximize digital digital digital seconds analog
about ok_about about ok_about minimize close_clock invoke
restore date


                     © 2006 Harry Robinson, Google
Reducing the Sequence:

•   Initial path length: 84 steps
•   Shortcut attempt 2 : repro sequence: 83 steps
•   Shortcut attempt 3 : repro sequence: 64 steps
•   Shortcut attempt 4 : repro sequence: 37 steps
•   Shortcut attempt 5 : repro sequence: 11 steps
•   Shortcut attempt 7 : repro sequence: 9 steps
•   Shortcut attempt 20 : repro sequence: 8 steps
•   Shortcut attempt 29 : repro sequence: 6 steps



                   © 2006 Harry Robinson, Google
# Repro Steps Over Time

                   90
                   80
                   70
# of Repro Steps




                   60
                   50
                   40
                   30
                   20
                   10
                   0
                        1

                            3

                                5

                                    7

                                        9

                                            11

                                                   13

                                                         15

                                                              17

                                                                    19

                                                                          21

                                                                               23

                                                                                    25

                                                                                         27

                                                                                              29
                                                 # of Shortcut Attempts




                                        © 2006 Harry Robinson, Google
Useful Regression Testing




        © 2006 Harry Robinson, Google
The Motivation

Q: What scenario does a developer use to test a fix?
A: The repro scenario you provided!




        type       format           spell check    print




                   © 2006 Harry Robinson, Google
The Gawain* Approach


 1.   Assign the same weight to each arc in a graph

 2. Choose a path through the graph

 3. Assign a low weight to each arc in that path

 4. Exercise paths in graph in weight-increasing order




* Graph Algorithm Without An Interesting Name
                          © 2006 Harry Robinson, Google
Assign the same weight to each arc
                         5



      5        5                    5       5



      5        5                    5       5




            © 2006 Harry Robinson, Google
Choose a path through the graph
                       5



    5        5                    5       5



    5        5                    5       5




          © 2006 Harry Robinson, Google
Assign a lower weight to each arc
           in that path
                        5



     1        1                    1       1



     5        5                    5       5


          Weight of this path = 4



           © 2006 Harry Robinson, Google
Execute all paths with total weight
    less than some amount “X”
                         5



      1        1                    1       1



      5        5                    5       5


           E.g., weight of this path = 8



            © 2006 Harry Robinson, Google
5



1       1                    1       1



5       5                    5       5


    Weight of this path = 8



     © 2006 Harry Robinson, Google
5



1       1                    1       1



5       5                    5       5


    Weight of this path = 8



     © 2006 Harry Robinson, Google
5



1       1                    1       1



5       5                    5       5


    Weight of this path = 9



     © 2006 Harry Robinson, Google
5



1       1                    1       1



5       5                    5       5


    Weight of this path = 11



     © 2006 Harry Robinson, Google
5



  1            1                    1       1



  5            5                    5       5


You end up “Cocooning” the regression path



            © 2006 Harry Robinson, Google
Machine Learning?




This developer        New bug                    This feature
    is new.           fix here.                    is new.


                 © 2006 Harry Robinson, Google
Observations on
Model-Based Testing




     © 2006 Harry Robinson, Google
Why Does Model-Based Testing Work?


                                                system under test
complexity

                             model


                                      speed

“… I think that less than 10 percent of most programs’ code is specific
to the application. Furthermore, that 10 percent is often the easiest 10 percent.
Therefore, it is not unreasonable to build a model program to use as an oracle.”
                                            –Boris Beizer, Black Box Testing, p.63


                              © 2006 Harry Robinson, Google
Economics of Model-Based Testing
 $
90000
80000
70000
60000
50000                                                                   cpu cost
40000                                                                   tester cost
30000       2080                4160                      52000
            hrs/yr              hrs/yr                    hrs/yr
20000
10000
    0
        1 tester, 1 cpu   2 testers, 2 cpus         1 tester, 10 cpus




                          © 2006 Harry Robinson, Google
Metrics Issues

Should you count bugs you prevented?



Should you count how many test cases you’ve generated?




                     © 2006 Harry Robinson, Google
Benefits of Model-Based Testing

    • Easy test case maintenance
    • Reduced costs
    • More test cases
    • Early bug detection
    • Increased bug count
    • Time savings
    • Time to address bigger test issues
    • Improved tester job satisfaction


             © 2006 Harry Robinson, Google
Obstacles to Model-Based Testing
• Comfort factor
   – This is not your parents’ test automation

• Skill sets
   – Need testers who can design

• Expectations
   – Models can be a significant upfront investment
   – Will never catch all the bugs

• Metrics
   – Bad metrics: bug counts, number of test cases
   – Better metrics: spec coverage, code coverage

                     © 2006 Harry Robinson, Google
A Useful Resource

The Model-Based Testing Home Page

   www.model-based-testing.org




           © 2006 Harry Robinson, Google
Recommended reading




     © 2006 Harry Robinson, Google
Thank
 you!


© 2006 Harry Robinson, Google

More Related Content

Similar to starwest-2006-mbt-tutorial

Its not about the tooling
Its not about the toolingIts not about the tooling
Its not about the toolingBram Vogelaar
 
Startup DNA: the formula behind successful startups in Silicon Valley (update...
Startup DNA: the formula behind successful startups in Silicon Valley (update...Startup DNA: the formula behind successful startups in Silicon Valley (update...
Startup DNA: the formula behind successful startups in Silicon Valley (update...Yevgeniy Brikman
 
Devops its not about the tooling
Devops its not about the toolingDevops its not about the tooling
Devops its not about the toolingBram Vogelaar
 
Leveling Up at JavaScript
Leveling Up at JavaScriptLeveling Up at JavaScript
Leveling Up at JavaScriptRaymond Camden
 
Jonathon Rochelle @ FOWA Feb 07
Jonathon Rochelle @ FOWA Feb 07Jonathon Rochelle @ FOWA Feb 07
Jonathon Rochelle @ FOWA Feb 07carsonsystems
 
From Config Management Sucks to #cfgmgmtlove
From Config Management Sucks to #cfgmgmtlove From Config Management Sucks to #cfgmgmtlove
From Config Management Sucks to #cfgmgmtlove Kris Buytaert
 
Reverse Chaos Method of Requirements Prioritisation
Reverse Chaos Method of Requirements Prioritisation  Reverse Chaos Method of Requirements Prioritisation
Reverse Chaos Method of Requirements Prioritisation Gena Drahun
 
User testing presentation
User testing presentationUser testing presentation
User testing presentationLindaKolker
 
Getting your mobile test automation process in place - using Cucumber and Cal...
Getting your mobile test automation process in place - using Cucumber and Cal...Getting your mobile test automation process in place - using Cucumber and Cal...
Getting your mobile test automation process in place - using Cucumber and Cal...Niels Frydenholm
 
Digitizing the dirty work
Digitizing the dirty workDigitizing the dirty work
Digitizing the dirty workIsaiah Suarez
 
User Tracking with Google Analytics and how it survives the break of the Glo...
 User Tracking with Google Analytics and how it survives the break of the Glo... User Tracking with Google Analytics and how it survives the break of the Glo...
User Tracking with Google Analytics and how it survives the break of the Glo...Rafael Biriba
 
Get responsive in 30 minutes (WordCamp Sofia)
Get responsive in 30 minutes (WordCamp Sofia)Get responsive in 30 minutes (WordCamp Sofia)
Get responsive in 30 minutes (WordCamp Sofia)Nickolay Ninarski
 
User first! 前端的最後一塊拼圖
User first! 前端的最後一塊拼圖User first! 前端的最後一塊拼圖
User first! 前端的最後一塊拼圖Maxis Kao
 
Adopting A Whole Team Approach To Quality
Adopting  A  Whole  Team  Approach  To  QualityAdopting  A  Whole  Team  Approach  To  Quality
Adopting A Whole Team Approach To QualityBen Carey
 
What an "RP" Wants
What an "RP" WantsWhat an "RP" Wants
What an "RP" WantsJohn McCrea
 
DeKnowledge - Try us
DeKnowledge - Try usDeKnowledge - Try us
DeKnowledge - Try usBob Pinto
 
Drupal commerce performance profiling and tunning using loadstorm experiments...
Drupal commerce performance profiling and tunning using loadstorm experiments...Drupal commerce performance profiling and tunning using loadstorm experiments...
Drupal commerce performance profiling and tunning using loadstorm experiments...Andy Kucharski
 
Usability Anonymous: A 12 Step Program for Better User Experiences
Usability Anonymous: A 12 Step Program for Better User ExperiencesUsability Anonymous: A 12 Step Program for Better User Experiences
Usability Anonymous: A 12 Step Program for Better User Experiencesjgoldman
 
Continuous Infrastructure First
Continuous Infrastructure FirstContinuous Infrastructure First
Continuous Infrastructure FirstKris Buytaert
 
Javascript sucks & frontend challenges @ClearSlide | while42 SF #7
Javascript sucks & frontend challenges @ClearSlide | while42 SF #7Javascript sucks & frontend challenges @ClearSlide | while42 SF #7
Javascript sucks & frontend challenges @ClearSlide | while42 SF #7While42
 

Similar to starwest-2006-mbt-tutorial (20)

Its not about the tooling
Its not about the toolingIts not about the tooling
Its not about the tooling
 
Startup DNA: the formula behind successful startups in Silicon Valley (update...
Startup DNA: the formula behind successful startups in Silicon Valley (update...Startup DNA: the formula behind successful startups in Silicon Valley (update...
Startup DNA: the formula behind successful startups in Silicon Valley (update...
 
Devops its not about the tooling
Devops its not about the toolingDevops its not about the tooling
Devops its not about the tooling
 
Leveling Up at JavaScript
Leveling Up at JavaScriptLeveling Up at JavaScript
Leveling Up at JavaScript
 
Jonathon Rochelle @ FOWA Feb 07
Jonathon Rochelle @ FOWA Feb 07Jonathon Rochelle @ FOWA Feb 07
Jonathon Rochelle @ FOWA Feb 07
 
From Config Management Sucks to #cfgmgmtlove
From Config Management Sucks to #cfgmgmtlove From Config Management Sucks to #cfgmgmtlove
From Config Management Sucks to #cfgmgmtlove
 
Reverse Chaos Method of Requirements Prioritisation
Reverse Chaos Method of Requirements Prioritisation  Reverse Chaos Method of Requirements Prioritisation
Reverse Chaos Method of Requirements Prioritisation
 
User testing presentation
User testing presentationUser testing presentation
User testing presentation
 
Getting your mobile test automation process in place - using Cucumber and Cal...
Getting your mobile test automation process in place - using Cucumber and Cal...Getting your mobile test automation process in place - using Cucumber and Cal...
Getting your mobile test automation process in place - using Cucumber and Cal...
 
Digitizing the dirty work
Digitizing the dirty workDigitizing the dirty work
Digitizing the dirty work
 
User Tracking with Google Analytics and how it survives the break of the Glo...
 User Tracking with Google Analytics and how it survives the break of the Glo... User Tracking with Google Analytics and how it survives the break of the Glo...
User Tracking with Google Analytics and how it survives the break of the Glo...
 
Get responsive in 30 minutes (WordCamp Sofia)
Get responsive in 30 minutes (WordCamp Sofia)Get responsive in 30 minutes (WordCamp Sofia)
Get responsive in 30 minutes (WordCamp Sofia)
 
User first! 前端的最後一塊拼圖
User first! 前端的最後一塊拼圖User first! 前端的最後一塊拼圖
User first! 前端的最後一塊拼圖
 
Adopting A Whole Team Approach To Quality
Adopting  A  Whole  Team  Approach  To  QualityAdopting  A  Whole  Team  Approach  To  Quality
Adopting A Whole Team Approach To Quality
 
What an "RP" Wants
What an "RP" WantsWhat an "RP" Wants
What an "RP" Wants
 
DeKnowledge - Try us
DeKnowledge - Try usDeKnowledge - Try us
DeKnowledge - Try us
 
Drupal commerce performance profiling and tunning using loadstorm experiments...
Drupal commerce performance profiling and tunning using loadstorm experiments...Drupal commerce performance profiling and tunning using loadstorm experiments...
Drupal commerce performance profiling and tunning using loadstorm experiments...
 
Usability Anonymous: A 12 Step Program for Better User Experiences
Usability Anonymous: A 12 Step Program for Better User ExperiencesUsability Anonymous: A 12 Step Program for Better User Experiences
Usability Anonymous: A 12 Step Program for Better User Experiences
 
Continuous Infrastructure First
Continuous Infrastructure FirstContinuous Infrastructure First
Continuous Infrastructure First
 
Javascript sucks & frontend challenges @ClearSlide | while42 SF #7
Javascript sucks & frontend challenges @ClearSlide | while42 SF #7Javascript sucks & frontend challenges @ClearSlide | while42 SF #7
Javascript sucks & frontend challenges @ClearSlide | while42 SF #7
 

More from tutorialsruby

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>tutorialsruby
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 

More from tutorialsruby (20)

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 

Recently uploaded

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

starwest-2006-mbt-tutorial

  • 1. Model-Based Testing Harry Robinson Google harryr@google.com © 2006 Harry Robinson, Google
  • 2. Goals for Today • Convey techniques for • How to model systems • How to generate tests • How to verify results • Communicate a mindset • Provide inspiration • Foster discontent © 2006 Harry Robinson, Google
  • 3. Non-Goals for Today • Specific tools • Interfacing with an application © 2006 Harry Robinson, Google
  • 4. What are the Problems of Software Testing? • Time is limited • Applications are complex • Requirements are fluid © 2006 Harry Robinson, Google
  • 5. What’s wrong with manual testing? © 2006 Harry Robinson, Google
  • 6. Manual testing is ok sometimes … Start Digital Stop Clock.exe Clock.exe © 2006 Harry Robinson, Google
  • 7. … but it can rarely go deep enough ? ? ? ? Analog Digital Start Digital Stop Clock.exe Clock.exe DblClk DblClk ? ? ? ? © 2006 Harry Robinson, Google
  • 8. What’s wrong with scripting? © 2006 Harry Robinson, Google
  • 9. The Villain of this Piece CurrentWindow = WFndWndC("Calculator", "SciCalc") WSetWndPosSiz(CurrentWindow, 88, 116, 260, 260) WMenuSelect("@2@2") CurrentWindow = WFndWndC("Calculator", "SciCalc") WSetWndPosSiz(CurrentWindow, 88, 116, 480, 317) WButtonClick("@32") WButtonClick("@27") WButtonClick("@38") WButtonClick("@58") WMenuSelect("@2@1") CurrentWindow = WFndWndC("Calculator", "SciCalc") WSetWndPosSiz(CurrentWindow, 88, 116, 260, 260) WMenuSelect("@2@1") Play "{Click 330, 131, Left}" WToolbarButtonClk("@2", "@6") • Awe-inspiring WToolbarButtonClk("@2", "@7") WToolbarButtonClk("@1", "@1") • Unchanging • Indecipherable © 2006 Harry Robinson, Google
  • 10. Scripts are ok for some uses … Test case 1: Start Digital Stop Start Analog Stop Test case 2: Start DblClk Stop Start DblClk Stop © 2006 Harry Robinson, Google
  • 11. … but they pile up quickly … Test case 1: Start Digital Stop Start Analog Stop Test case 2: Start DblClk Stop Start DblClk Stop Test case 3: Start Digital DblClk Stop Start DblClk Analog Stop Test case 4: Start DblClk DblClk Digital DblClk DblClk Stop Start Analog Stop Test case 5: … © 2006 Harry Robinson, Google
  • 12. … and what are you left with? Test case 1: Start Digital Stop Start Analog Stop Test case 2: Start DblClk Stop Start DblClk Stop Test case 3: Start Digital DblClk Stop Start DblClk Analog Stop Test case 4: Start DblClk DblClk Digital DblClk DblClk Stop Start Analog Stop Test case 5: Start Digital Digital Stop Start Analog Stop Test case 6: Start DblClk Stop Start Analog DblClk Stop Test case 7: Start Digital DblClk Stop Start Digital DblClk Analog Stop Test case 8: Start DblClk DblClk Digital Analog DblClk DblClk Stop Test case 9: … © 2006 Harry Robinson, Google
  • 13. What is a model? • A model is a description of a system. • Models are simpler than the systems they describe. • Models help us understand and predict the system’s behavior. © 2006 Harry Robinson, Google
  • 14. What is model-based testing? “Model-based testing is a testing technique where the runtime behavior of an implementation under test is checked against predictions made by a formal specification, or model.” - Colin Campbell, MSR In other words • A model describes how a system should behave in response to an action. • Supply the action and see if the system responds as you expect. © 2006 Harry Robinson, Google
  • 15. Traditional Automated Testing Imagine that this projector is the software you are testing. © 2006 Harry Robinson, Google
  • 16. Traditional Automated Testing Typically, testers automate by creating static scripts. © 2006 Harry Robinson, Google
  • 17. Traditional Automated Testing Given enough time, these scripts will cover the behavior. © 2006 Harry Robinson, Google
  • 18. Traditional Automated Testing But what happens when the software’s behavior changes? © 2006 Harry Robinson, Google
  • 19. So What’s a Model? • A model is a description of a system’s behavior. • Models are simpler than the systems they describe. • Models help us understand and predict the system’s behavior. © 2006 Harry Robinson, Google
  • 20. Model-Based Testing Now, imagine that the top projector is your model. © 2006 Harry Robinson, Google
  • 21. Model-Based Testing The model generates tests to cover the behavior. © 2006 Harry Robinson, Google
  • 22. Model-Based Testing … and when the behavior changes… © 2006 Harry Robinson, Google
  • 23. Model-Based Testing … so do the tests. © 2006 Harry Robinson, Google
  • 24. Using Models to Test • What type of model do I use? • How do I create the model? • How do I choose tests? • How do I verify results? © 2006 Harry Robinson, Google
  • 25. Many Types of Models • States • Monkeys • Sets • Grammars • Combinations • Other © 2006 Harry Robinson, Google
  • 26. Creating a Model © 2006 Harry Robinson, Google
  • 27. We All Use Mental Models Already Digital hmm … if I am in the Analog display and I execute the Digital action I should end up in the Digital display © 2006 Harry Robinson, Google
  • 28. State Table Representation Analog Digital Digital StartState Action EndState Analog Digital Digital © 2006 Harry Robinson, Google
  • 29. Exercise 1 Modeling a Website Based on “Model-Based Testing: Not for Dummies” by Jeff Feldstein © 2006 Harry Robinson, Google
  • 30. State Table Representation StartState Action EndState HomePage ImageTab ImagePage HomePage NewsTab NewsPage ImagePage HomeTab HomePage ImagePage NewsTab NewsPage NewsPage HomeTab HomePage NewsPage ImageTab ImagePage © 2006 Harry Robinson, Google
  • 31. Exercise 2 Modeling Notepad © 2006 Harry Robinson, Google
  • 32. Notepad Model Type A Close Start Cancel Close Delete A No © 2006 Harry Robinson, Google
  • 33. Notepad State Table StartState Action EndState NotRunning Start MainWindow WindowEmpty TypeA WindowDirty WindowEmpty Close NotRunning WindowDirty Delete WindowEmpty WindowDirty Close SaveDialog SaveDialog Cancel WindowDirty SaveDialog No NotRunning © 2006 Harry Robinson, Google
  • 34. Exercise 3 Modeling Wordpad © 2006 Harry Robinson, Google
  • 35. Wordpad Model Delete A Close Type A Type A Cancel Start Close Close Cancel No No © 2006 Harry Robinson, Google
  • 36. Wordpad State Table StartState Action EndState NotRunning Start MainWindow WindowEmpty1 TypeA WindowDirty WindowEmpty1 Close NotRunning WindowDirty Delete WindowEmpty2 WindowDirty Close SaveDialog1 WindowEmpty2 TypeA WindowDirty WindowEmpty2 Cancel SaveDialog2 SaveDialog1 Cancel WindowDirty SaveDialog1 No NotRunning SaveDialog2 Cancel WindowEmpty2 SaveDialog2 No NotRunning © 2006 Harry Robinson, Google
  • 37. Exercise 4 Modeling Clock using Rules Digital © 2006 Harry Robinson, Google
  • 38. Modeling Clock States In our discussion of the Clock behavior, we only tracked a few data values in the application: Running was described as Digital Framed Running was described as Analog Unframed © 2006 Harry Robinson, Google
  • 39. Modeling Clock Actions We also tracked how our actions change those values: Running Analog Framed Digital Digital Running Digital Framed © 2006 Harry Robinson, Google
  • 40. So, we can replace this model … Analog Digital Start Digital Stop Clock.exe Stop Analog Start Clock.exe DblClk DblClk DblClk DblClk Start Stop Clock.exe Stop Start Clock.exe © 2006 Harry Robinson, Google
  • 41. … with a state variable model Analog Digital Start Digital Stop Stopped Running Running Stopped Analog Analog Digital Digital Framed Framed Framed Framed Stop Analog Start DblClk DblClk DblClk DblClk Stopped Start Running Running Stop Stopped Analog Analog Digital Digital Unframed Unframed Unframed Unframed Stop Start © 2006 Harry Robinson, Google
  • 42. Rules for the Stop action • If the Clock is Running, then the user can execute the ‘Stop’ action. • The ‘Stop’ action puts you in Stopped mode static void Stop( ) requires (AppStatus == AppValues.Running); Stop { AppStatus = AppValues.Stopped; } Clock.exe © 2006 Harry Robinson, Google
  • 43. Rules for the SelectDigital action • If the Clock is Running and Framed, then the user can execute the ‘SelectDigital’ action • The ‘SelectDigital’ action puts you in Digital mode static void SelectDigital( ) requires (AppStatus == AppValues.Running) Select && (FrameStatus == FrameValues.Framed); Digital { ModeStatus = ModeValues.Digital; } © 2006 Harry Robinson, Google
  • 44. A generated state table! STARTSTATE ACTION ENDSTATE Stopped Analog Framed Start Running Analog Framed Running Analog Framed Stop Stopped Analog Framed Running Analog Framed SelectAnalog Running Analog Framed Running Analog Framed SelectDigital Running Digital Framed Running Analog Framed DblClk Running Analog Unframed Running Digital Framed Stop Stopped Digital Framed Running Digital Framed SelectAnalog Running Analog Framed Running Digital Framed SelectDigital Running Digital Framed Running Digital Framed DblClk Running Digital Unframed Running Analog Unframed Stop Stopped Analog Unframed Running Analog Unframed DblClk Running Analog Framed Stopped Digital Framed Start Running Digital Framed Running Digital Unframed Stop Stopped Digital Unframed Running Digital Unframed DblClk Running Digital Framed Stopped Analog Unframed Start Running Analog Unframed Stopped Digital Unframed Start Running Digital Unframed © 2006 Harry Robinson, Google
  • 45. A state diagram © 2006 Harry Robinson, Google
  • 46. Generating Tests from a Model © 2006 Harry Robinson, Google
  • 47. Generating Test Sequences We can use the machine-readable model to create test sequences: • Random walk • All transitions • Shortest paths first • Most likely paths first © 2006 Harry Robinson, Google
  • 48. A Random Walk © 2006 Harry Robinson, Google
  • 49. A sequence that hits all transitions © 2006 Harry Robinson, Google
  • 50. An all-transitions sequence 1. Start 9. Start 2. Analog 10. Double Click 3. Digital 11. Analog 4. Digital 12. Double Click 5. Stop 13. Stop 6. Start 14. Start 7. Double Click 15. Double Click 8. Stop 16. Stop © 2006 Harry Robinson, Google
  • 51. All paths of length 2 © 2006 Harry Robinson, Google
  • 52. All paths of length 3 © 2006 Harry Robinson, Google
  • 53. All paths of length 4 © 2006 Harry Robinson, Google
  • 54. All paths of length < 5 1. Start, Stop 2. Start, Analog, Stop 3. Start, Analog, Analog, Stop 4. Start, Digital, Analog, Stop 5. Start, Double Click, Double Click, Stop © 2006 Harry Robinson, Google
  • 55. Exercise 5 Brainstorming Traversals © 2006 Harry Robinson, Google
  • 56. How would you test this? © 2006 Harry Robinson, Google
  • 57. Pathological © 2006 Harry Robinson, Google
  • 58. Closer in … © 2006 Harry Robinson, Google
  • 59. Partial state table for the maze *west end of long hall South maze of twisty little passages maze of twisty little passages Up twisty little maze of passages maze of twisty little passages NW twisty maze of little passages maze of twisty little passages North maze of little twisty passages maze of twisty little passages NE twisting maze of little passages maze of twisty little passages West maze of little twisting passages maze of twisty little passages East little twisty maze of passages maze of twisty little passages SW little maze of twisty passages © 2006 Harry Robinson, Google
  • 60. Executing the Test Actions 1. Start 2. Analog 3. Digital 4. Digital 5. Stop 6. Start 7. Double Click 8. Stop © 2006 Harry Robinson, Google
  • 61. Exercise 6 Modeling from a Spec © 2006 Harry Robinson, Google
  • 62. “Accessing an Account” 1. customer needs to log in to use the system 2. customer stays logged in to the system until she logs out 3. customer starts with no account 4. customer can create an account 5. customer can delete her account 6. customer can open an existing account 7. customer can close an existing account © 2006 Harry Robinson, Google
  • 63. Verifying the Outcomes © 2006 Harry Robinson, Google
  • 64. Oracles • Crashes • Prediction • Checking • Pre-oracling • Heuristics • Filtering + Humans • Assertions © 2006 Harry Robinson, Google
  • 65. Exercise 7 Monkeying an Input Field Inspired by Noel Nyman’s article “Using Monkey Test Tools” © 2006 Harry Robinson, Google
  • 66. Monkey Models Nothing I do 1.2 should make this app crash… a P, a P, ab P, ab P 2, abc P, P, P, P, scbuild1 Type 5 containing message laurie Bill's October ?A ? v?-0Qrg+ 'cQ?_<$ ` Z`i7c} oV? E1X … nov 31, 2000 Oct, 2000 dates Wednesday … alike. In Word documents, for example … 3 M note RNL in Office 10 © 2006 Harry Robinson, Google
  • 67. Predicting the Outcome StartState Action EndState Analog Digital Digital © 2006 Harry Robinson, Google
  • 68. Exercise 8 Oracling the Square Root Function © 2006 Harry Robinson, Google
  • 69. © 2006 Harry Robinson, Google
  • 70. Exercise 9 Oracling the Sine Function Academy Artworks Inspired by Doug Hoffman’s article “Heuristic Test Oracles” © 2006 Harry Robinson, Google
  • 71. sin 2(x) + cos 2(x) =1 cos(x) = sin(x-pi) sin2(x) + sin2(x-pi) = 1 © 2006 Harry Robinson, Google
  • 72. Modeling with Sets © 2006 Harry Robinson, Google
  • 73. Exercise 10 Modeling Search © 2006 Harry Robinson, Google
  • 74. © 2006 Harry Robinson, Google
  • 75. © 2006 Harry Robinson, Google
  • 76. © 2006 Harry Robinson, Google
  • 77. +ruby +ruby -ruby -pragmatic +pragmatic +pragmatic 3143 files 12 files 70 files +ruby +pragmatic 3513 files 82 files © 2006 Harry Robinson, Google
  • 78. 3513 – 12 = ? +ruby +ruby -ruby -pragmatic +pragmatic +pragmatic 3143 files 12 files 70 files +ruby +pragmatic 3513 files 82 files © 2006 Harry Robinson, Google
  • 79. Modeling with Grammars Expr ::= IDENT | NUMBER | "let" Ident = Expr "in" Expr | Expr + Expr | Expr - Expr © 2006 Harry Robinson, Google
  • 80. How a Production Grammar Works © 2006 Harry Robinson, Google
  • 81. Exercise 11 Modeling HTML © 2006 Harry Robinson, Google
  • 82. A mini-html grammar {seed}:=<html>{body}</html>; {body}:={body}<P>{body}|<H1>{body2}</H1>|<H4>{body2}</H4>; {body2}:=<font color="red"> {body3} </font>|<font color="blue"> {body3} </font>; {body3}:=<U>{body4}</U>|{body4}; {body4}:=<I> {body5} </I> | {body5}; {body5}:=the quick brown fox; © 2006 Harry Robinson, Google
  • 83. Grammar Example 1 Modeling Arithmetic Expressions 100 * 5 / (6 – 5.01 * 3.14159) Inspired by Pete TerMaat’s article “Adventures in Automated Testing” © 2006 Harry Robinson, Google
  • 84. Evaluate the following expressions 1. 10 * 1.0 * 0.1 * 6.0 * 1.16666666667 * 1.0 * 1.14285714286 * 5.25 2. 2 * 2.5 * 0.4 * 4.0 * 1.25 * 1.0 * 0.8 * 5.25 3. 4 * 0.5 * 3.5 * 1.0 * 0.285714285714 * 3.0 * 0.166666666667 * 42.0 4. 2 * 5.0 * 0.2 * 1.5 * 1.0 * 2.66666666667 * 1.125 * 4.66666666667 5. 5 * 1.6 * 1.0 * 0.5 * 1.75 * 0.428571428571 * 0.333333333333 * 42.0 6. 4 * 2.0 * 0.75 * 1.5 * 0.444444444444 * 0.75 * 2.66666666667 * 5.25 7. 6 * 1.5 * 0.777777777778 * 0.428571428571 * 1.33333333333 * 0.25 * 7.0 * 6.0 8. 2 * 1.5 * 0.333333333333 * 10.0 * 0.5 * 0.8 * 1.5 * 7.0 9. 5 * 0.6 * 1.66666666667 * 0.2 * 1.0 * 1.0 * 10.0 * 4.2 © 2006 Harry Robinson, Google
  • 85. 42 5 * 8.4 5 * 1.0 * 8.4 1 * 5.0 * 1.0 * 8.4 1 * 1.0 * 5.0 * 1.0 * 8.4 10 * 0.1 * 1.0 * 5.0 * 1.0 * 8.4 8 * 1.25 * 0.1 * 1.0 * 5.0 * 1.0 * 8.4 7 * 1.14285714286 * 1.25 * 0.1 * 1.0 * 5.0 * 1.0 * 8.4 © 2006 Harry Robinson, Google
  • 86. Evaluate the following expression 10 * 0.6 * 1.5 * 0.666666666667 * 1.0 * 1.0 * 0.833333333333 * 1.2 * 1.5 * 0.666666666667 * 1.33333333333 * 0.375 * 1.66666666667 * 1.0 * 2.0 * 1.0 * 0.9 * 0.777777777778 * 1.0 * 0.428571428571 * 3.0 * 0.666666666667 * 1.5 * 0.222222222222 * 0.5 * 5.0 * 2.0 * 0.4 * 2.0 * 0.5 * 0.75 * 1.33333333333 * 0.75 * 2.33333333333 * 1.42857142857 * 0.7 * 1.0 * 1.28571428571 * 1.0 * 0.333333333333 * 2.0 * 0.833333333333 * 0.2 * 6.0 * 1.33333333333 * 0.375 * 0.666666666667 * 1.0 * 2.0 * 2.25 * 0.222222222222 * 4.5 * 0.888888888889 * 0.125 * 4.0 * 2.0 * 0.75 * 1.0 * 1.5 * 0.333333333333 * 2.33333333333 * 0.428571428571 * 3.0 * 0.888888888889 * 0.625 * 0.2 * 8.0 * 0.375 * 0.333333333333 * 7.0 * 1.42857142857 * 0.1 * 3.0 * 3.33333333333 * 1.0 * 0.6 * 0.333333333333 * 4.0 * 0.5 * 2.5 * 0.5 * 1.4 * 1.14285714286 * 0.25 * 0.5 * 7.0 * 0.428571428571 * 2.0 * 1.0 * 0.5 * 0.666666666667 * 4.5 * 0.333333333333 * 2.33333333333 * 0.571428571429 * 1.75 * 0.428571428571 * 2.0 * 0.5 * 14.0 © 2006 Harry Robinson, Google
  • 87. Grammar Example 2 Modeling C Code static void TestCase(){ while( Fun("L21") ){ L22: break; }} else { L3:{ L31: goto L22; L32: goto L31; }} © 2006 Harry Robinson, Google
  • 88. Grammar Model for a Subset of C Statement :: if ( BooleanCondition ) { Statement } else { Statement } Statement :: while ( BooleanCondition ) { Statement } Statement :: { Statement Statement } Statement :: break; Statement :: goto Label; Statement :: Label : Statement Statement :: ExpressionStatement; ExpressionStatement :: MethodCall BooleanExpression :: MethodCall MethodCall :: Fun(Label) Based on “A High-Level Modular Definition of the Semantics of C#” - Boerger, Fruja, Gervasi, Stark © 2006 Harry Robinson, Google
  • 89. Deriving Programs from the Grammar { Statement } { if ( Boolean ) { Statement } else { Statement } } { if ( MethodCall ) { Statement } else { Statement } } { if ( MethodCall ) { Statement Statement } else { Statement } } © 2006 Harry Robinson, Google
  • 90. Tests Generated from the Grammar suite123.cs suite321.cs static void TestCase(){ static void TestCase(){ L: L: if ( Fun("L1") ){ if ( Fun("L1") ){ L2: L2: if ( Fun("L21") ){ while( Fun("L21") ){ L22: goto L; L22: } break; else{ }} L23: goto L; else{ }} L3: else{ { L3: L31: goto L; { L32: goto L31; L31: goto L32; }}} L32: goto L; }}} “Experiments on Semantics Based Testing of a Compiler” - Esin, Novikov, Yavorskiy © 2006 Harry Robinson, Google
  • 91. Exercise 12 Modeling Combinations © 2006 Harry Robinson, Google
  • 92. Exercise 13 Selecting Sandwiches Inspired by an example in Lou Tylee’s book “Visual C# Express for Kids” © 2006 Harry Robinson, Google
  • 93. Setting Up the Combinations Bread Cheese H MU MA L T white none ham mustard mayo lettuce tomato wheat american no_ham no_must no_mayo no_lett no_tom rye swiss Using James Bach’s AllPairs program from www.satisfice.com © 2006 Harry Robinson, Google
  • 94. Generating the Pairs TEST CASES case Bread Cheese H M MA L T 1 white none ham mustard mayo lettuce tomato 2 white american no_ham no_must no_mayo no_lett no_tom 3 wheat none no_ham mustard no_mayo lettuce no_tom 4 wheat american ham no_must mayo no_lett tomato 5 rye swiss ham mustard no_mayo no_lett tomato 6 rye swiss no_ham no_must mayo lettuce no_tom 7 white none ham no_must no_mayo no_lett no_tom 8 white american no_ham mustard mayo lettuce tomato 9 wheat swiss ham mustard mayo no_lett no_tom 10 rye none no_ham no_must no_mayo lettuce tomato 11 rye american ham mustard no_mayo lettuce no_tom 12 white swiss no_ham no_must no_mayo no_lett tomato © 2006 Harry Robinson, Google
  • 95. But, did we miss any behavior of interest? © 2006 Harry Robinson, Google
  • 96. Exercise 14 Modeling the Triangle Inspired by B J Rollison’s conference paper “Dissecting the Triangle Problem” © 2006 Harry Robinson, Google
  • 97. © 2006 Harry Robinson, Google
  • 98. Exhaustion? for ( a=0; a<=32767; a++) for ( b=0; b<=32767; b++) for ( c=0; c<=32767; c++) evaluate( a, b, c); © 2006 Harry Robinson, Google
  • 99. Exercise 15 Modeling Google Maps © 2006 Harry Robinson, Google
  • 100. © 2006 Harry Robinson, Google
  • 101. © 2006 Harry Robinson, Google
  • 102. 0.60 miles © 2006 Harry Robinson, Google
  • 103. Trip #115 Trip start: 47.7945, -122.493 Trip end: 47.74753 -122.36585 Google route distance is 102.0 miles Straightline distance is 6.7 miles Ratio is 15.2 --------------------- SUSPICIOUS... © 2006 Harry Robinson, Google
  • 104. © 2006 Harry Robinson, Google
  • 105. © 2006 Harry Robinson, Google
  • 106. © 2006 Harry Robinson, Google
  • 107. Checking Driving Directions © 2006 Harry Robinson, Google
  • 108. Checking Driving Directions © 2006 Harry Robinson, Google
  • 109. The Long Road Home © 2006 Harry Robinson, Google
  • 110. What Kinds of Bugs do Models Find? © 2006 Harry Robinson, Google
  • 111. The Incredible Shrinking Clock Start Maximize Stop Start Minimize Stop ! Start Restore Stop © 2006 Harry Robinson, Google
  • 112. That Was the Year that Wasn’t Start Minimize Stop Start Restore Date ! © 2006 Harry Robinson, Google
  • 113. What Kinds of Bugs do Models NOT Find? © 2006 Harry Robinson, Google
  • 114. © 2006 Harry Robinson, Google
  • 115. © 2006 Harry Robinson, Google
  • 116. © 2006 Harry Robinson, Google
  • 117. © 2006 Harry Robinson, Google
  • 118. Where is Model-Based Testing Heading? 1. Security Testing 2. Shortening Bug Repro Scenarios 3. Meaningful Regression Testing 4. Machine Learning? © 2006 Harry Robinson, Google
  • 119. Security Testing “The testing method developed in the PROTOS project is uniquely practical .... Tests are conducted by bombing software with illegally formatted or unexpected input.” Tekes - National Technology Agency of Finland CERT Advisories • CA-2001-18 Multiple Vulnerabilities in LDAP Implementations • CA-2002-03 Multiple Vulnerabilities in SNMP Implementations • CA-2003-06 Multiple Vulnerabilities in SIP Implementations • CA-2003-11 Multiple Vulnerabilities in Lotus Notes and Domino © 2006 Harry Robinson, Google
  • 120. Shortening Repro Scenarios © 2006 Harry Robinson, Google
  • 121. The Motivation “The fewer steps that it takes to reproduce a bug, the fewer places the programmer has to look (usually). If you make it easier to find the cause and test the change, you reduce the effort required to fix the problem. Easy bugs gets fixed even if they are minor.“ - from Testing Computer Software © 2006 Harry Robinson, Google
  • 122. The Beeline Approach A repro path is simply another traversal through the state model, so … 1. Choose any 2 nodes in the repro path 2. Find the shortest path between them 3. Execute the spliced ‘shortcut’ path 4. Evaluate the results and repeat © 2006 Harry Robinson, Google
  • 123. The repro path reduction problem 1 2 3 © 2006 Harry Robinson, Google
  • 124. Random walk finds a bug 1 2 3 … but the repro path is inconveniently long © 2006 Harry Robinson, Google
  • 125. 1. Choose any 2 nodes in the path 1 2 3 © 2006 Harry Robinson, Google
  • 126. 2. Find shortest path between them 1 2 3 © 2006 Harry Robinson, Google
  • 127. 3. Execute the spliced shortcut path 1 2 3 The bug repro’ed - this is the new shortest path © 2006 Harry Robinson, Google
  • 128. Continue trimming … 1 A 2 B 3 © 2006 Harry Robinson, Google
  • 129. … until you stop. 1 2 3 © 2006 Harry Robinson, Google
  • 130. Why Use a Model for Reducing? • The model can detect (and therefore reduce) both crashing AND non-crashing bugs. • Finding a shortcut is simple in a model, so the reduction is more efficient. • Finding bugs is good. Getting them fixed is better. © 2006 Harry Robinson, Google
  • 131. That Was The Year That Wasn’t Start Minimize Stop Start Restore Date © 2006 Harry Robinson, Google
  • 132. An 84-step repro sequence invoke about ok_about no_title doubleclick seconds restore seconds doubleclick doubleclick date about ok_about restore gmt maximize doubleclick doubleclick date seconds date close_clock invoke close_clock invoke close_clock invoke seconds date restore about ok_about no_title doubleclick digital doubleclick doubleclick no_title doubleclick no_title doubleclick seconds restore restore doubleclick doubleclick gmt analog maximize date digital minimize restore minimize close_clock invoke restore digital date minimize close_clock invoke maximize gmt digital restore doubleclick doubleclick about ok_about maximize digital digital digital seconds analog about ok_about about ok_about minimize close_clock invoke restore date © 2006 Harry Robinson, Google
  • 133. Reducing the Sequence: • Initial path length: 84 steps • Shortcut attempt 2 : repro sequence: 83 steps • Shortcut attempt 3 : repro sequence: 64 steps • Shortcut attempt 4 : repro sequence: 37 steps • Shortcut attempt 5 : repro sequence: 11 steps • Shortcut attempt 7 : repro sequence: 9 steps • Shortcut attempt 20 : repro sequence: 8 steps • Shortcut attempt 29 : repro sequence: 6 steps © 2006 Harry Robinson, Google
  • 134. # Repro Steps Over Time 90 80 70 # of Repro Steps 60 50 40 30 20 10 0 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 # of Shortcut Attempts © 2006 Harry Robinson, Google
  • 135. Useful Regression Testing © 2006 Harry Robinson, Google
  • 136. The Motivation Q: What scenario does a developer use to test a fix? A: The repro scenario you provided! type format spell check print © 2006 Harry Robinson, Google
  • 137. The Gawain* Approach 1. Assign the same weight to each arc in a graph 2. Choose a path through the graph 3. Assign a low weight to each arc in that path 4. Exercise paths in graph in weight-increasing order * Graph Algorithm Without An Interesting Name © 2006 Harry Robinson, Google
  • 138. Assign the same weight to each arc 5 5 5 5 5 5 5 5 5 © 2006 Harry Robinson, Google
  • 139. Choose a path through the graph 5 5 5 5 5 5 5 5 5 © 2006 Harry Robinson, Google
  • 140. Assign a lower weight to each arc in that path 5 1 1 1 1 5 5 5 5 Weight of this path = 4 © 2006 Harry Robinson, Google
  • 141. Execute all paths with total weight less than some amount “X” 5 1 1 1 1 5 5 5 5 E.g., weight of this path = 8 © 2006 Harry Robinson, Google
  • 142. 5 1 1 1 1 5 5 5 5 Weight of this path = 8 © 2006 Harry Robinson, Google
  • 143. 5 1 1 1 1 5 5 5 5 Weight of this path = 8 © 2006 Harry Robinson, Google
  • 144. 5 1 1 1 1 5 5 5 5 Weight of this path = 9 © 2006 Harry Robinson, Google
  • 145. 5 1 1 1 1 5 5 5 5 Weight of this path = 11 © 2006 Harry Robinson, Google
  • 146. 5 1 1 1 1 5 5 5 5 You end up “Cocooning” the regression path © 2006 Harry Robinson, Google
  • 147. Machine Learning? This developer New bug This feature is new. fix here. is new. © 2006 Harry Robinson, Google
  • 148. Observations on Model-Based Testing © 2006 Harry Robinson, Google
  • 149. Why Does Model-Based Testing Work? system under test complexity model speed “… I think that less than 10 percent of most programs’ code is specific to the application. Furthermore, that 10 percent is often the easiest 10 percent. Therefore, it is not unreasonable to build a model program to use as an oracle.” –Boris Beizer, Black Box Testing, p.63 © 2006 Harry Robinson, Google
  • 150. Economics of Model-Based Testing $ 90000 80000 70000 60000 50000 cpu cost 40000 tester cost 30000 2080 4160 52000 hrs/yr hrs/yr hrs/yr 20000 10000 0 1 tester, 1 cpu 2 testers, 2 cpus 1 tester, 10 cpus © 2006 Harry Robinson, Google
  • 151. Metrics Issues Should you count bugs you prevented? Should you count how many test cases you’ve generated? © 2006 Harry Robinson, Google
  • 152. Benefits of Model-Based Testing • Easy test case maintenance • Reduced costs • More test cases • Early bug detection • Increased bug count • Time savings • Time to address bigger test issues • Improved tester job satisfaction © 2006 Harry Robinson, Google
  • 153. Obstacles to Model-Based Testing • Comfort factor – This is not your parents’ test automation • Skill sets – Need testers who can design • Expectations – Models can be a significant upfront investment – Will never catch all the bugs • Metrics – Bad metrics: bug counts, number of test cases – Better metrics: spec coverage, code coverage © 2006 Harry Robinson, Google
  • 154. A Useful Resource The Model-Based Testing Home Page www.model-based-testing.org © 2006 Harry Robinson, Google
  • 155. Recommended reading © 2006 Harry Robinson, Google
  • 156. Thank you! © 2006 Harry Robinson, Google