Behaviour	
  Driven	
  Development	
  
 Beyond	
  “Given,	
  When,	
  Then”	
  


            Antony	
  Marcano	
  
The	
  Telephone	
  Game	
  




             h<p://www.brokenpicturetelephone.com/	
  
What	
  is	
  BDD?	
  

Beyond	
  “Given,	
  When,	
  Then”	
  
BDD	
  Origins	
  
	
  ‘ The	
  deeper	
  I	
  got	
  into	
  TDD,	
  the	
  more	
  I	
  felt	
  that	
  my	
  own	
  
    journey	
  had	
  been	
  less	
  of	
  a	
  wax-­‐on,	
  wax-­‐off	
  process	
  of	
  
    gradual	
  mastery	
  than	
  a	
  series	
  of	
  blind	
  alleys.	
  I	
  remember	
  
    thinking	
  “If	
  only	
  someone	
  had	
  told	
  me	
  that!”…	
  	
  
	
  I	
  decided	
  it	
  must	
  be	
  possible	
  to	
  present	
  TDD	
  in	
  a	
  way	
  that	
  
    gets	
  straight	
  to	
  the	
  good	
  stuff	
  and	
  avoids	
  all	
  the	
  piFalls.	
  	
  
    My	
  response	
  is	
  behaviour-­‐driven	
  development	
  (BDD).	
  	
  
	
  Over	
  Lme,	
  BDD	
  has	
  grown	
  to	
  encompass	
  the	
  wider	
  picture	
  
    of	
  agile	
  analysis	
  and	
  automated	
  acceptance	
  tesLng.’	
  
	
  -­‐Dan	
  North	
  
BDD	
  Origins	
  -­‐	
  Shortened	
  
“ 	
  Behaviour	
  Driven	
  Development	
  (BDD)	
  builds	
  
      upon	
  Test-­‐Driven	
  Development	
  (TDD)	
  by	
  
      formalising	
  the	
  good	
  habits	
  of	
  the	
  best	
  TDD	
  
      pracMMoners.	
  ”	
  –	
  The	
  Cucumber	
  Book,	
  Aslak	
  Hellesøy,	
  Ma<	
  Wynne	
  
Some	
  ‘Good	
  Habits’	
  

     Slice	
  VerMcally	
  
Work	
  from	
  the	
  outside-­‐in	
  
 One	
  example	
  at	
  a	
  Mme	
  
Slice	
  VerMcally	
  
SoWware	
  Components	
  
                                                                                                 SoWware	
  Components	
  
                                                                                                  (modules/classes)	
  
                                                                                                   (modules/classes)	
  




                                                           Lme	
  
                                                           Lme	
  



2009
                                                                          Sprint	
  nn
                                                                        IteraMon	
  	
   	
  
                                                                       Sprint	
  n+1…	
  
                                                                     IteraMon	
  n+1…	
  




                                                                                                                                     Story	
  
                                                                                                                             User	
  Login	
   A	
  


                                                                                                                             User	
  Story	
  B	
  
                                                                                                                             Create	
  album	
  
                                                                                                                                                       TradiMonally,	
  development	
  is	
  sliced	
  horizontally	
  




                                                                                                                             User	
  Story	
  C	
  
                                                                                                                              Share	
  photos	
  
                                                                          Sprint	
  x
                                                                        IteraMon	
  	
  x	
  




                                                                                                                             User	
  Story	
  D	
  
                                                                                                                             Private	
  albums	
  
       …but defers feedback (often, until it’s too late)
8
SoWware	
  Components	
  
                                                                        (modules/classes)	
  




                                      Lme	
  



2009
                                                                                                  Share	
  photos	
  




                                                IteraMon	
  n	
  
                                                                                                  Create	
  album	
  


                                                                                                  Share	
  photos	
  

                                                IteraMon	
  n+1	
  
                                                                                                                          VerMcal	
  slicing	
  




                                                                                                         Login	
  


                                                                                                   Create	
  album	
  


                                                                                                   Share	
  photos	
  
                                                IteraMon	
  x	
  




                                                                                                  Private	
  albums	
  
       …results in earlier feedback
9
Work	
  from	
  the	
  outside-­‐in	
  
Outside-­‐in	
  
One	
  example	
  at	
  a	
  Mme	
  
One	
  example	
  at	
  a	
  Mme	
  
Expressing	
  Examples	
  

    Given,	
  When,	
  Then	
  
       And	
  beyond	
  
Given	
  When	
  Then	
  
	
  Given	
  <some	
  iniMal	
  context>	
  
	
  When	
  <something	
  happens>	
  
	
  Then	
  <some	
  expectaMon>	
  
Given	
  When	
  Then	
  
	
  Given	
  <some	
  iniMal	
  context>	
  
	
  	
  [and	
  some	
  addiMonal	
  context]	
  
	
  When	
  <something	
  happens>	
  
	
  	
  [and	
  something	
  else	
  happens]	
  
	
  Then	
  <some	
  expectaMon>	
  
	
  	
  [and	
  some	
  more	
  expectaMons]	
  
A	
  Typical	
  IllustraMon	
  
Scenario: Login Successfully!
  Given I am on the home-page!
  When I enter the username ‘antony’!
  And I enter the password ‘p4$$w0rd’!
  And I click ‘login’!
  Then I should be logged in	
  	
  




 What’s	
  wrong	
  with	
  this	
  example?	
  
A	
  Be<er	
  IllustraMon	
  
Scenario: Login Successfully!
 When I login as ‘antony’ with the password ‘p4$$w0rd’!
 Then I should be logged in	
  	
  




               Why	
  is	
  it	
  be<er?	
  
Task	
  Analysis	
  

A	
  li<le	
  UX	
  for	
  our	
  BDD	
  
•  Pitching	
  it	
  right…	
  
    –  Goals 	
                          	
  e.g.	
  Withdraw	
  Cash	
  
        •  Tasks	
  	
  	
   	
  IdenMfy	
  to	
  bank	
  
           	
   	
              	
  	
  	
  	
  	
   	
  Request	
  amount	
  
                                                                                                   }	
        Just	
  right	
  



                       –  (inter)acLons	
  



                                                                                                   }	
  
                         	
     	
        	
         	
  Insert	
  Card	
  
                                                                                                              Too	
  
                         	
     	
        	
  	
     	
  Enter	
  Pin	
  
                                                                                                              low	
  
                         	
     	
        	
         	
  Press	
  “Withdraw	
  Cash” 	
     	
         	
     level	
   	
  	
  
                                                                                                                	
  
                         	
     	
        	
         	
  Enter	
  amount	
  
                         	
     	
        	
         	
  Press	
  OK	
  
For	
  example…	
  

When I attempt to add, the number ‘2’ and the number ’3’!




                             task	
  

                     }	
  
                         acMons	
  

                                        h<p://cukesalad.info	
  
Some	
  nice	
  side-­‐effects	
  
          Encourages	
  descripMon	
  	
  
    of	
  UI	
  interacMons	
  in	
  one	
  place	
  

Makes	
  it	
  easier	
  to	
  execute	
  scenarios	
  
       via	
  different	
  interfaces	
  
Discussion	
  

 QuesMons?	
  
   Ideas?	
  
 Feedback?	
  
antony@riverglide.com 	
   	
  @AntonyMarcano	
  
talktous@riverglide.com	
   	
  @RiverGlide/rs	
  
  	
   	
     	
     	
     	
     	
     	
     	
     	
     	
     	
  h<p://twi<er.com/RiverGlide/rs	
  

h<p://cukesalad.info 	
   	
   	
  #cukesalad	
  
h<p://RiverGlide.com	
   	
   	
  @RiverGlide	
  	
  

Behaviour Driven Development - Beyond given when then

  • 1.
    Behaviour  Driven  Development   Beyond  “Given,  When,  Then”   Antony  Marcano  
  • 2.
    The  Telephone  Game   h<p://www.brokenpicturetelephone.com/  
  • 3.
    What  is  BDD?   Beyond  “Given,  When,  Then”  
  • 4.
    BDD  Origins    ‘ The  deeper  I  got  into  TDD,  the  more  I  felt  that  my  own   journey  had  been  less  of  a  wax-­‐on,  wax-­‐off  process  of   gradual  mastery  than  a  series  of  blind  alleys.  I  remember   thinking  “If  only  someone  had  told  me  that!”…      I  decided  it  must  be  possible  to  present  TDD  in  a  way  that   gets  straight  to  the  good  stuff  and  avoids  all  the  piFalls.     My  response  is  behaviour-­‐driven  development  (BDD).      Over  Lme,  BDD  has  grown  to  encompass  the  wider  picture   of  agile  analysis  and  automated  acceptance  tesLng.’    -­‐Dan  North  
  • 5.
    BDD  Origins  -­‐  Shortened   “  Behaviour  Driven  Development  (BDD)  builds   upon  Test-­‐Driven  Development  (TDD)  by   formalising  the  good  habits  of  the  best  TDD   pracMMoners.  ”  –  The  Cucumber  Book,  Aslak  Hellesøy,  Ma<  Wynne  
  • 6.
    Some  ‘Good  Habits’   Slice  VerMcally   Work  from  the  outside-­‐in   One  example  at  a  Mme  
  • 7.
  • 8.
    SoWware  Components   SoWware  Components   (modules/classes)   (modules/classes)   Lme   Lme   2009 Sprint  nn IteraMon       Sprint  n+1…   IteraMon  n+1…   Story   User  Login   A   User  Story  B   Create  album   TradiMonally,  development  is  sliced  horizontally   User  Story  C   Share  photos   Sprint  x IteraMon    x   User  Story  D   Private  albums   …but defers feedback (often, until it’s too late) 8
  • 9.
    SoWware  Components   (modules/classes)   Lme   2009 Share  photos   IteraMon  n   Create  album   Share  photos   IteraMon  n+1   VerMcal  slicing   Login   Create  album   Share  photos   IteraMon  x   Private  albums   …results in earlier feedback 9
  • 10.
    Work  from  the  outside-­‐in  
  • 11.
  • 12.
    One  example  at  a  Mme  
  • 13.
    One  example  at  a  Mme  
  • 14.
    Expressing  Examples   Given,  When,  Then   And  beyond  
  • 15.
    Given  When  Then    Given  <some  iniMal  context>    When  <something  happens>    Then  <some  expectaMon>  
  • 16.
    Given  When  Then    Given  <some  iniMal  context>      [and  some  addiMonal  context]    When  <something  happens>      [and  something  else  happens]    Then  <some  expectaMon>      [and  some  more  expectaMons]  
  • 17.
    A  Typical  IllustraMon   Scenario: Login Successfully! Given I am on the home-page! When I enter the username ‘antony’! And I enter the password ‘p4$$w0rd’! And I click ‘login’! Then I should be logged in     What’s  wrong  with  this  example?  
  • 18.
    A  Be<er  IllustraMon   Scenario: Login Successfully! When I login as ‘antony’ with the password ‘p4$$w0rd’! Then I should be logged in     Why  is  it  be<er?  
  • 19.
    Task  Analysis   A  li<le  UX  for  our  BDD  
  • 20.
    •  Pitching  it  right…   –  Goals    e.g.  Withdraw  Cash   •  Tasks        IdenMfy  to  bank                  Request  amount   }   Just  right   –  (inter)acLons   }          Insert  Card   Too            Enter  Pin   low          Press  “Withdraw  Cash”       level                Enter  amount          Press  OK  
  • 21.
    For  example…   WhenI attempt to add, the number ‘2’ and the number ’3’! task   }   acMons   h<p://cukesalad.info  
  • 22.
    Some  nice  side-­‐effects   Encourages  descripMon     of  UI  interacMons  in  one  place   Makes  it  easier  to  execute  scenarios   via  different  interfaces  
  • 23.
    Discussion   QuesMons?   Ideas?   Feedback?  
  • 24.
    antony@riverglide.com    @AntonyMarcano   talktous@riverglide.com    @RiverGlide/rs                        h<p://twi<er.com/RiverGlide/rs   h<p://cukesalad.info      #cukesalad   h<p://RiverGlide.com      @RiverGlide