Behavior  Driven  Tes.ng  (BDT)     in     Agile  
What  is  Tes*ng  on  Agile  projects?  
Story   planning  and   wri/ng   Showcase   IPM   Automa/on   (execu/on,   QA  kickoff   maintenance)   Agile  Tes.ng     in  an  Itera.on Manual  +   Exploratory   Story  kickoff   Tes/ng   BA  /  QA   Test  Scenario   Volleyball   Wri/ng   Implement   Test   Automa/on  
A  prac*ce  that  makes  Agile  Teams     successful?   Test  Automa.on  
A  prac*ce  that  makes  Agile  Teams   unsuccessful?   Test  Automa.on  
The  Test  Pyramid   •  “Succeeding  with  Agile”  –  Mike  Cohn   •  Mar*n  Fowler  –  Test  Pyramid   –  hCp://mar*nfowler.com/bliki/TestPyramid.html  
Ideal  Test  Pyramid   Func/onal  Tests  (GUI)   •  Developers  &  /  QA  team   API  Tests   •  Developers  &  /  QA  team   Integra/on  tests   •  Developers   Component  tests   •  Developers   Unit  Tests   •  Developers   Cost  /  Effort   Time  
Test  Pyramid  reality   Development  team   Test  Pyramid   QA  team   Test  Pyramid  
Test  Pyramid  –  An*  PaCern  
Evolu*on  of  Test  Frameworks   Behavior   Driven   Development   (BDD)   Op/mized   scripts   Record  &   Playback     Core   Framework  
Behavior  Driven  Development     (BDD)  
RED   REFACTOR   GREEN  
Behavior  Driven  Tes*ng   (BDT)  
Expected  Func/onality:     The  customer  should  be  able  to  withdraw   money  from  his  account  via  an  ATM  machine  
BDD  Example:   Given  the  account  has  balance  of  5000   When  the  customer  requests  1000   Then  the  account  is  debited  by  1000  
BDT  Example:   Given  the  account  is  in  credit   And  the  dispenser  contains  cash     When  the  customer  requests  cash     Then  ensure  the  account  is  debited   And  ensure  cash  is  dispensed   And  ensure  the  card  is  returned  
New  Expected  Func/onality:     The  customer  should  be  able  to  withdraw   money  from  his  account  only  if  his  card  is   valid  
BDT  Example  -­‐  updated:   Given  the  account  is  in  credit   And  the  card  is  valid   And  the  dispenser  contains  cash     When  the  customer  requests  cash     Then  ensure  the  account  is  debited   And  ensure  cash  is  dispensed   And  ensure  the  card  is  returned  
Case  Study  
Requirements   •  Guest  User  is  able  to  search  for  a  flight  for  a   single  traveller   •  Ability  to  specify  contact  informa*on  for   person  booking  the  flight  
Search   Contact   Search     Results   Informa/on  
Contact  Details  
Test  specifica*on  styles   •  Impera*ve     •  Declara*ve  
Impera*ve  style   Given  I  am  a  guest  user  on  the  Indigo  home  page   And  I  select  “round”  trip  op*on   And  I  select  “Pune”  from  the  origin  dropdown   And  I  select  “Bangalore”  from  the  des*na*on  drop  down   And  I  select  departure  date  as  “5  July  2012”   And  I  select  returning  date  as  “25  July  2012”     When  I  click  on  Search     Then  I  should  see  the  search  results  page     And  I  should  see  at  least  1  op*on  for  my  criteria     ...  
…   When  I  select  the  “first”  op*on   Then  I  am  on  the  Contact  Informa*on  page     When  I  enter  first  name  as  “foo”   And  I  enter  last  name  as  “bar”   …   …   And  I  click  the  “Select  and  Con/nue”  buCon     Then  I  should  be  on  the  next  page    
Declara*ve  style   Given  I  am  a  guest  user     When  I  search  for  flight  op*ons  for  a  “one-­‐way”  trip   for  “1”  “Adult”  from  “Delhi”  to  “Bangalore”   And  I  select  the  “first”  flight   And  I  enter  “valid”  contact  details  for  “traveller1”     Then  I  am  able  to  Save  and  Con*nue  
Func/onal  Tests  (GUI)   •  Developers  &  /  QA  team   API  Tests   •  Developers  &  /  QA  team   Integra/on  tests   •  Developers   Component  tests   •  Developers   Unit  Tests   •  Developers  
What  does  BDT  do  for  me?  
What  BDT  does  NOT  do  for  me?   •  Replace  tes*ng  granular  func*onality     –  ONLY  when  it  has  just  been  developed  
Steps  to  follow  to  implement  BDT  
Current  state   Tests  running  on  Hudson  /  Jenkins   Since  1st  test  was  automated   Feature  files   33   Scenarios   65   Smoke  tests  execu*on  *me   15  minutes   Regression  tests  execu*on  *me   45  minutes   Test  case  repository  (manual  +   Cucumber  .feature  files  with   automated)   appropriate  tagging   Project  Management  tool   Mingle  
Tools  to  enable  BDD  /  BDT   •  Cucumber   •  JBehave   •  SpecFlow   •  Twist  
Anand.Bagmar@thoughtworks.com   abagmar@gmail.com   ThoughtWorks®  

Anand Bagmar - Behavior Driven Testing (BDT) in Agile

  • 1.
    Behavior  Driven  Tes.ng  (BDT)     in     Agile  
  • 2.
    What  is  Tes*ng  on  Agile  projects?  
  • 3.
    Story   planning  and   wri/ng   Showcase   IPM   Automa/on   (execu/on,   QA  kickoff   maintenance)   Agile  Tes.ng     in  an  Itera.on Manual  +   Exploratory   Story  kickoff   Tes/ng   BA  /  QA   Test  Scenario   Volleyball   Wri/ng   Implement   Test   Automa/on  
  • 4.
    A  prac*ce  that  makes  Agile  Teams     successful?   Test  Automa.on  
  • 5.
    A  prac*ce  that  makes  Agile  Teams   unsuccessful?   Test  Automa.on  
  • 6.
    The  Test  Pyramid   •  “Succeeding  with  Agile”  –  Mike  Cohn   •  Mar*n  Fowler  –  Test  Pyramid   –  hCp://mar*nfowler.com/bliki/TestPyramid.html  
  • 7.
    Ideal  Test  Pyramid   Func/onal  Tests  (GUI)   •  Developers  &  /  QA  team   API  Tests   •  Developers  &  /  QA  team   Integra/on  tests   •  Developers   Component  tests   •  Developers   Unit  Tests   •  Developers   Cost  /  Effort   Time  
  • 9.
    Test  Pyramid  reality   Development  team   Test  Pyramid   QA  team   Test  Pyramid  
  • 10.
    Test  Pyramid  –  An*  PaCern  
  • 11.
    Evolu*on  of  Test  Frameworks   Behavior   Driven   Development   (BDD)   Op/mized   scripts   Record  &   Playback     Core   Framework  
  • 12.
  • 13.
  • 14.
  • 15.
    Expected  Func/onality:     The  customer  should  be  able  to  withdraw   money  from  his  account  via  an  ATM  machine  
  • 16.
    BDD  Example:   Given  the  account  has  balance  of  5000   When  the  customer  requests  1000   Then  the  account  is  debited  by  1000  
  • 17.
    BDT  Example:   Given  the  account  is  in  credit   And  the  dispenser  contains  cash     When  the  customer  requests  cash     Then  ensure  the  account  is  debited   And  ensure  cash  is  dispensed   And  ensure  the  card  is  returned  
  • 18.
    New  Expected  Func/onality:     The  customer  should  be  able  to  withdraw   money  from  his  account  only  if  his  card  is   valid  
  • 19.
    BDT  Example  -­‐  updated:   Given  the  account  is  in  credit   And  the  card  is  valid   And  the  dispenser  contains  cash     When  the  customer  requests  cash     Then  ensure  the  account  is  debited   And  ensure  cash  is  dispensed   And  ensure  the  card  is  returned  
  • 20.
  • 22.
    Requirements   •  Guest  User  is  able  to  search  for  a  flight  for  a   single  traveller   •  Ability  to  specify  contact  informa*on  for   person  booking  the  flight  
  • 23.
    Search   Contact   Search     Results   Informa/on  
  • 26.
  • 27.
    Test  specifica*on  styles   •  Impera*ve     •  Declara*ve  
  • 28.
    Impera*ve  style   Given  I  am  a  guest  user  on  the  Indigo  home  page   And  I  select  “round”  trip  op*on   And  I  select  “Pune”  from  the  origin  dropdown   And  I  select  “Bangalore”  from  the  des*na*on  drop  down   And  I  select  departure  date  as  “5  July  2012”   And  I  select  returning  date  as  “25  July  2012”     When  I  click  on  Search     Then  I  should  see  the  search  results  page     And  I  should  see  at  least  1  op*on  for  my  criteria     ...  
  • 29.
    …   When  I  select  the  “first”  op*on   Then  I  am  on  the  Contact  Informa*on  page     When  I  enter  first  name  as  “foo”   And  I  enter  last  name  as  “bar”   …   …   And  I  click  the  “Select  and  Con/nue”  buCon     Then  I  should  be  on  the  next  page    
  • 30.
    Declara*ve  style   Given  I  am  a  guest  user     When  I  search  for  flight  op*ons  for  a  “one-­‐way”  trip   for  “1”  “Adult”  from  “Delhi”  to  “Bangalore”   And  I  select  the  “first”  flight   And  I  enter  “valid”  contact  details  for  “traveller1”     Then  I  am  able  to  Save  and  Con*nue  
  • 31.
    Func/onal  Tests  (GUI)   •  Developers  &  /  QA  team   API  Tests   •  Developers  &  /  QA  team   Integra/on  tests   •  Developers   Component  tests   •  Developers   Unit  Tests   •  Developers  
  • 32.
    What  does  BDT  do  for  me?  
  • 33.
    What  BDT  does  NOT  do  for  me?   •  Replace  tes*ng  granular  func*onality     –  ONLY  when  it  has  just  been  developed  
  • 34.
    Steps  to  follow  to  implement  BDT  
  • 39.
    Current  state   Tests  running  on  Hudson  /  Jenkins   Since  1st  test  was  automated   Feature  files   33   Scenarios   65   Smoke  tests  execu*on  *me   15  minutes   Regression  tests  execu*on  *me   45  minutes   Test  case  repository  (manual  +   Cucumber  .feature  files  with   automated)   appropriate  tagging   Project  Management  tool   Mingle  
  • 40.
    Tools  to  enable  BDD  /  BDT   •  Cucumber   •  JBehave   •  SpecFlow   •  Twist  
  • 41.
    Anand.Bagmar@thoughtworks.com   abagmar@gmail.com   ThoughtWorks®