Building the "right" regression suite using Behavior Driven Testing (BDT)

61
Building the “right” regression suite using Behavior Driven Tes5ng (BDT) Anand Bagmar So#ware Quality Evangelist Principal Consultant,

description

Presented in World Conference - Next Generation Testing, Bangalore on 11th July 2013

Transcript of Building the "right" regression suite using Behavior Driven Testing (BDT)

Page 1: Building the "right" regression suite using Behavior Driven Testing (BDT)

Building  the  “right”  regression  suite  using  Behavior  Driven  Tes5ng  

(BDT)  Anand  Bagmar  

So#ware  Quality  Evangelist  Principal  Consultant,      

Page 2: Building the "right" regression suite using Behavior Driven Testing (BDT)

[email protected]    [email protected]  

           @BagmarAnand  

 about.me/anand.bagmar  

About  me  

Page 3: Building the "right" regression suite using Behavior Driven Testing (BDT)

What  do  you  expect  from  this  session?  

Page 4: Building the "right" regression suite using Behavior Driven Testing (BDT)

Case  Study  

•  MulHple,  long  running  projects  

•  Legacy  applicaHons  

•  Integrated  

Page 5: Building the "right" regression suite using Behavior Driven Testing (BDT)

•  Limited  /  flaky  /  long-­‐running  AutomaHon    

•  Long  regression  cycle  •  Huge  cost  of  fixing  defects  

FuncHonal  TesHng  Challenges  

Page 6: Building the "right" regression suite using Behavior Driven Testing (BDT)

•  BriRle  •  LiRle  /  less  value  •  No  visibility  into  what  is  tested  •  Maintenance  nightmare  •  Outdated  •  Expensive  

As  a  result  

Page 7: Building the "right" regression suite using Behavior Driven Testing (BDT)

Biggest  problem  

•  Trust  deficit  on  the  team  –  In  exisHng  AutomaHon  –  In  manual  tesHng  

•  Finger  poinHng  /  blame  game  

Page 8: Building the "right" regression suite using Behavior Driven Testing (BDT)

My  Case  Study  

Page 9: Building the "right" regression suite using Behavior Driven Testing (BDT)
Page 10: Building the "right" regression suite using Behavior Driven Testing (BDT)

Concept  #  1    

The  Test  Pyramid  

Page 11: Building the "right" regression suite using Behavior Driven Testing (BDT)

AutomaHon  –  A  Safety  Net  

Page 12: Building the "right" regression suite using Behavior Driven Testing (BDT)

•  “Succeeding  with  Agile”  –  Mike  Cohn  

•  MarHn  Fowler  –  Test  Pyramid  –  hRp://marHnfowler.com/bliki/TestPyramid.html  

The  Test  Pyramid  

Page 13: Building the "right" regression suite using Behavior Driven Testing (BDT)

Func%onal  Tests  (GUI)  

Web  Service  Tests  

View  Tests  

JavaScript  Tests  

Integra%on  tests  

Component  tests  

Unit  Tests  

Test  AutomaHon  Pyramid  

Manual  /  Exploratory  TesHng  

Product  under  test  

Ideal  Test  Pyramid  

Business-­‐facing  Tests  

Technology-­‐facing  Tests  

•  Cost  •  Effort  •  Time  

Page 14: Building the "right" regression suite using Behavior Driven Testing (BDT)
Page 15: Building the "right" regression suite using Behavior Driven Testing (BDT)

Test  Pyramid  reality  

Development  team  Test  Pyramid   QA  team  

Test  Pyramid  

Page 16: Building the "right" regression suite using Behavior Driven Testing (BDT)

Func%onal  Tests  (GUI)  

Web  Service  Tests  

…  

…    

Unit  Tests  

Manual  /  Exploratory  TesHng  

Test    Ice-­‐cream  cone  

Business-­‐facing  Tests  

Technology-­‐facing  Tests  

Test  Pyramid  –  AnH  PaRern  

Product    under  test  

Page 17: Building the "right" regression suite using Behavior Driven Testing (BDT)

Func%onal  Tests  (GUI)  

Web  Service  Tests  

…  

…  

Unit  Tests  

Manual  /  Exploratory  TesHng  

Product  under  test  

Ideal  Test  Pyramid  

Business-­‐facing  Tests  

Technology-­‐facing  Tests  

IdenHfy  the  right  type  of  tests  that  sit  on  top  of  the  Test  Pyramid  

Page 18: Building the "right" regression suite using Behavior Driven Testing (BDT)

Concept  #  2    

BDD  &  BDT  

Page 19: Building the "right" regression suite using Behavior Driven Testing (BDT)

Behavior  Driven  Development    (BDD)  

Page 20: Building the "right" regression suite using Behavior Driven Testing (BDT)

RED  

GREEN  REFACTOR  

Page 21: Building the "right" regression suite using Behavior Driven Testing (BDT)

Behavior  Driven  TesHng  (BDT)  

Page 22: Building the "right" regression suite using Behavior Driven Testing (BDT)

The  Big  Picture  

•  How  is  this  funcHonality  going  to  be  used  by  the  end-­‐user?    

•  What  is  their  thought  process  going  to  be  when  using  this  product?    

•  What  is  the  “core-­‐business-­‐value”  I  am  delivering  to  the  end-­‐user?  

Page 23: Building the "right" regression suite using Behavior Driven Testing (BDT)

Concept  #  3    

Test  Specifica5on  Styles  

Page 24: Building the "right" regression suite using Behavior Driven Testing (BDT)

Test  specificaHon  styles  

•  ImperaHve    •  DeclaraHve  

Page 25: Building the "right" regression suite using Behavior Driven Testing (BDT)

Search    Search  Results  

Contact  Informa%on  

An  example  For  SomeAwesomeAirlines  website  –    A  Guest  User  can  …  

Page 26: Building the "right" regression suite using Behavior Driven Testing (BDT)

ImperaHve  style  Given  I  am  a  guest  user  on  the  home  page  And  I  choose  “round”  trip  opHon  And  I  select  “Chicago”  from  the  origin  dropdown  And  I  select  “San  Francisco”  from  the  desHnaHon  drop  down  And  I  select  departure  date  as  “5  December  2013”  And  I  select  returning  date  as  “25  December  2013”    When  I  click  on  Search    Then  I  should  see  the  search  results  page    And  I  should  see  at  least  1  opHon  for  my  criteria    ...    

Page 27: Building the "right" regression suite using Behavior Driven Testing (BDT)

…  When  I  select  the  “first”  opHon  Then  I  am  on  the  Contact  InformaHon  page    When  I  enter  first  name  as  “foo”  And  I  enter  last  name  as  “bar”  …  …  And  I  click  the  “Select  and  Con%nue”  buRon    Then  I  should  be  on  the  next  page    

Page 28: Building the "right" regression suite using Behavior Driven Testing (BDT)

Given  I  am  a  guest  user    When  I  search  for  flight  opHons  for  a  “one-­‐way”  trip  for  “1”  “Adult”  from  “Chicago”  to  “San  Francisco”  And  I  select  the  “first”  flight  And  I  enter  “valid”  contact  details  for  “traveller1”    Then  I  am  able  to  Save  and  ConHnue  

DeclaraHve  style  

Page 29: Building the "right" regression suite using Behavior Driven Testing (BDT)

References  

•  Ben  Mabey  -­‐  hRp://benmabey.com/2008/05/19/imperaHve-­‐vs-­‐declaraHve-­‐scenarios-­‐in-­‐user-­‐stories.html  

•  Alister  ScoR  -­‐  hRp://waHrmelon.com/2010/12/10/cucumber-­‐imperaHve-­‐or-­‐declaraHve-­‐that-­‐is-­‐the-­‐quesHon/  

Page 30: Building the "right" regression suite using Behavior Driven Testing (BDT)

My  Case  Study  

Page 31: Building the "right" regression suite using Behavior Driven Testing (BDT)
Page 32: Building the "right" regression suite using Behavior Driven Testing (BDT)
Page 33: Building the "right" regression suite using Behavior Driven Testing (BDT)
Page 34: Building the "right" regression suite using Behavior Driven Testing (BDT)

•  Remove  the  ambiguity  •  Same  visibility  for  all  

Page 35: Building the "right" regression suite using Behavior Driven Testing (BDT)

How  did  we  accomplish  this?  

Page 36: Building the "right" regression suite using Behavior Driven Testing (BDT)
Page 37: Building the "right" regression suite using Behavior Driven Testing (BDT)

•  IdenHfy  business  flows  based  on  personas,  and  how  the  personas  use  the  business  funcHonality,  or,  

•  IdenHfy  business  flows,  and  how  different  user  personas  can  use  the  business  flows  

Page 38: Building the "right" regression suite using Behavior Driven Testing (BDT)
Page 39: Building the "right" regression suite using Behavior Driven Testing (BDT)

1st  candidate  •  Automate!  •  High  Value,  Low  Cost  

2nd  candidate  •  Automate!  •  High  Value,  High  Cost  

Can  Automate?  •  Manual  Regression?  

•  Low  Value,  Low  Cost  

Do  Not  Automate  •  Manual  Regression!  

•  Low  Value,  High  Cost  

High  Value  

High    Cost  

Low  Value  

Low  Cost  

Page 40: Building the "right" regression suite using Behavior Driven Testing (BDT)

Who  is  doing  the  acHon?  

What  is  the  business  funcHonality?  

Depicts  a  user  flow  /  user  journey  

Given  auc%oneer  creates  an  aucHon  And  5  vehicles  are  added  to  the  aucHon            When  auc%oneer  starts  the  aucHon  And  auc%oneer  sets  a  starHng  bid  of  5000  And  buyer_1  bids  And  buyer_2  bids    Then  auc%oneer  Sells  the  vehicle  And  buyer_2  wins  the  vehicle  

Page 41: Building the "right" regression suite using Behavior Driven Testing (BDT)

What  next?  

•  IdenHficaHon  of  Tests  

•  Automate  it!  

Page 42: Building the "right" regression suite using Behavior Driven Testing (BDT)

Automate  tests  that  are  valuable,  not  because  you  can  or  like  to  automate!  

Page 43: Building the "right" regression suite using Behavior Driven Testing (BDT)

Who  is  doing  the  acHon?  

What  is  the  business  funcHonality?  

Depicts  a  user  flow  /  user  journey  

Ac5ons  and  verifica5ons  happen  implicitly  

Given  auc%oneer  creates  an  aucHon  And  5  vehicles  are  added  to  the  aucHon            When  auc%oneer  starts  the  aucHon  And  auc%oneer  sets  a  starHng  bid  of  5000  And  buyer_1  bids  And  buyer_2  bids    Then  auc%oneer  Sells  the  vehicle  And  buyer_2  wins  the  vehicle  

Page 44: Building the "right" regression suite using Behavior Driven Testing (BDT)

Delete profile

Page 45: Building the "right" regression suite using Behavior Driven Testing (BDT)

1st  candidate  •  Automate!  •  High  Value,  Low  Cost  

2nd  candidate  •  Automate!  •  High  Value,  High  Cost  

Can  Automate?  •  Manual  Regression?  

•  Low  Value,  Low  Cost  

Do  Not  Automate  •  Manual  Regression!  

•  Low  Value,  High  Cost  

High  Value  

High    Cost  

Low  Value  

Low  Cost  

Page 46: Building the "right" regression suite using Behavior Driven Testing (BDT)

Final  state  Project  Management  tool   Mingle  

Test  case  repository  (manual  +  automated)  

Cucumber  .feature  files  with  appropriate  tagging  

Feature  files  /  Scenarios   33  /  65  

#  of  Manual  Tests   0  

Tests  running  on  CI  (Jenkins)   Since  the  1st  test  was  automated  

Smoke  tests  execuHon  Hme   15  minutes  

Regression  tests  execuHon  Hme   45  minutes  

Page 47: Building the "right" regression suite using Behavior Driven Testing (BDT)

How  did  this  technique  ever  become  successful?  

Page 48: Building the "right" regression suite using Behavior Driven Testing (BDT)

Context  is  KING!  

Domain  

Product-­‐under-­‐test  

Distributed  Teams   Skills  

Capability  

Tech  Stack  

Process   Tools  

Page 49: Building the "right" regression suite using Behavior Driven Testing (BDT)

BDT  will  ….  

•  NOT  work  in  isola5on  

Page 50: Building the "right" regression suite using Behavior Driven Testing (BDT)

Requires  more  dedicated  and  focused  tesHng  (manual  /  exploratory)  

Page 51: Building the "right" regression suite using Behavior Driven Testing (BDT)

Requires  lower  layers  of  Test  Pyramid  to  be  automaHon  and  implemented  well!  

Page 52: Building the "right" regression suite using Behavior Driven Testing (BDT)

Func%onal  Tests  (GUI)  

Web  Service  Tests  

…  

…  

Unit  Tests  

Manual  /  Exploratory  TesHng  

Product  under  test  

Ideal  Test  Pyramid  

Business-­‐facing  Tests  

Technology-­‐facing  Tests  

IdenHfy  the  right  type  of  tests  that  sit  on  top  of  the  Test  Pyramid  

Page 53: Building the "right" regression suite using Behavior Driven Testing (BDT)

AddiHonally  …  

•  Builds  and  deployments  are  automated  

•  FuncHonal  Performance  and  Concurrent  TesHng  automated  and  run  on  demand  

Page 54: Building the "right" regression suite using Behavior Driven Testing (BDT)

BDT  Value  ProposiHon  

Page 55: Building the "right" regression suite using Behavior Driven Testing (BDT)

?  

Incrementally  build  User  Flows  

Regress  required  Product  Business  

Value  

Tests  in-­‐sync  

Effec%ve  Tests      

Remove  ambiguity  

Understand  new  

func%onality  

Living  Documenta%on  

Onboarding  

Page 56: Building the "right" regression suite using Behavior Driven Testing (BDT)

Executable  Specs  

BDT  Scenarios  

   

Page 57: Building the "right" regression suite using Behavior Driven Testing (BDT)
Page 58: Building the "right" regression suite using Behavior Driven Testing (BDT)

Func%onal  Tests  (GUI)  

Web  Service  Tests  

…  

…  

Unit  Tests  

BDT  helps  iden5fy  the  “right”  type  of  regression  tests!  

Manual  /  Exploratory  TesHng  

Product  under  test  

Ideal  Test  Pyramid  

Page 59: Building the "right" regression suite using Behavior Driven Testing (BDT)

Tools  to  enable  BDT  

•  Whiteboards  •  Mind  maps  •  Flow  charts  •  Collabora5on!!  

Page 60: Building the "right" regression suite using Behavior Driven Testing (BDT)

Automate  the  top  layer  

Automate  using  -­‐      •  BDD  Tools,  or,    •  Directly  in  any  appropriate  programming  language  /  tools  

Page 61: Building the "right" regression suite using Behavior Driven Testing (BDT)

[email protected]    [email protected]  

           @BagmarAnand  

 about.me/anand.bagmar  

Thank  you