SHIFT LEFT @ mp ila eten Michaël Pila eten
X X X X X X V V
SHIFT LEFT 4 ty pes WHY ?
• 21% o f  pr ojects f ail due to  r equir eme nts Standish Gr oup C HA OS  R epor t • 57% o f de f ects  ar e made  be f or e c oding starts Lauese n &  Vin ter – Pr e v enti ng R equir ement s De f ect s • W orking So ftwar e  o v er  C ompr ehen siv e  Docum ent ation Agil e  Manif esto
SHIFT LEFT 4 ty pes 3  TYPES
TRADITIONAL
MODEL - BASED
INCREMENT AL VVVVVV
SHIFT LEFT 4 ty pes 3 FLA V OURS
De v elop er   T esting User  T esting TDD A TDD BDD
UNIT  TESTING TES T  FIRST A PPR O A CH RED  / GRE EN   / REF A CT OR OBJECTIV E:  HIGH  QUA LITY C ODE
• Unit   T ests  ar e c on structed  wit h as serti on s  th at  c an   check • That   a  functi on   perf orms  a  calcula ti on  and  r et urns a n  e xpected  r esult • That   a  functi on   chang es  th e stat e  o f an  appl icat io n • That   a  functi on   call s  an ot her  functi on • Unit   T ests  shoul d be : • Automat ed • Easy  to  implemen t  an d mai nt ai n • W rit te n in  th e  same  la nguag e  as the   pr oductio n  c ode • Simple  (easy)   to   run • V ery  f ast  to  e x ecute
• Eff ecti v e Unit  T ests  =  T rustw ort hy  Unit   T ests • T o  be  trustw ort hy ,  the y  ar e e xpec te d  to   be  FR AID • F  - F ast For immedi ate   fe edb ack .  It  should  be   po ss ib le  to  run  ma ny   tes ts  in very  lit tle  time . • R  - R epea ta ble The  tes t  c an   be   r an   at  an y  time ,  autom ati c a l l y  or  user tr igger ed • A  - At omic Al l unit  tes ts  or  a subs et  c an   be   r an   in any   r an dom  order,  without  af fe cting  the  resul ts • I  - Isol at ed The  Un it  Te st   shoul d  st riv e  to  exer cis e  onl y   the  in ten ded  code • D  - Det ermini stic E ve ry  time   the  tes t  is   r an ,  it  should  produce  the  sa me  resul t
• 3 - step  pat te rn f or Unit   T esti ng:  Arr ang e  - A ct  - As sert • Arr ang e:  • Pr epa r e  th e  e x ecutio n  en vir on ment • Not  al wa ys  nec es sary • A ct:  • Ex ecute  th e ope r at io n  bei ng  te sted • Mandat ory • As sert:  • Check  th e  r esult  pr oduc ed  b y  th e ope r at io n • Mandatory • 1  unit   te st  =  1  as serti on
Si ngle  ite r at io ns  o f  a  f e w minute s, i n  steps: 1. DEV c onsider s  the   c hang e  up ha nd 2. DEV i dent if ies  th e  small est  chang e 3. DEV w rit es  a (f ai li ng) uni t  te st Des crib in g  an d  ide nti f y in g  an   ex am p le   of   the  code be hav ior  neede d  for  the  change 4. DEV w rit es  th e c ode 5. DEV run s  th e unit   te st  to  v erif y  th e  chang e 6. DEV r e f acto r s 7. DEV i mpr o v es  th e  design
All unit t es ts  automated be f or e c oding starts Immed iate f ee dback R e f actor ed c ode Le gacy c ode Lar g e  bodies o f  Unit T es ts W e ha v e  build the thing right
DEV  METHODOL OG Y A C CEPT ANCE   TES TING SP ECIFICA TION  B Y EXA MPLE C OLLABORA TIVE  W ORKSH OPS
All ac c eptanc e tests r eady  be f or e c oding starts Automati on  not r equ ir ed F r ame w ork s Does n ’t embr ac e chang e Dupl icat e automation (UT  & A T)
DEV  METHODOL OG Y USE R  ST ORIES &  SCEN ARIOS DOMAIN SPE CIFIC  LAN GUA GE CUS T OMER  CEN TRIC  AP PR O A CH
• F ea tur e  <ti tl e> • AS  A  <r ol e> • I W ANT  <acti on> • SO  TH A T  <bu sin ess v al ue > • Scenar io   <ti tl e> • GIVE N  <c on t e x t> • A ND  <m or e c on t e x t> • WHE N  <acti on> • A ND  <other  ac ti on> • TH EN  <ou t c ome> • A ND  <m or e out c omes> • Descri p ti on  of  the   F ea tur e • St ak ehol der  and/ or  user  r ol e • Action  t o  be undert ak en • Busine ss  v al ue   pr o vide d  (r a ti ona le ) • Descri p ti on  of  the   Scenar io • P r ec ondi ti ons • Actions • Expect ed  out c omes
• Us er  St ori es  captur e  busines s  r equir ement s  & H L  functi on al it y • Sc ena rio s  ar e  deriv ed  fr om  Us er  St ori es, wit h  mor e  deta il s  an d specifi cs • Us er  St ori es  (and  ac c ept an c e  cr it eria ) may   be  aut omat ed • Sc ena rio s  mus t  be  aut omat ed • Us er  St ori es  ar e docum ent ed  visual ly   (task  boa r d) • Sc ena rio s  ar e  docum ent ed  in  c ode  (or  phr ase  te mpla te s) Us er  St ories  vs .  BDD  Sc enari os
Les s docume ntation L ink  with iter ativ e SD L C F r ame w ork s Le arn ing curv e Chang e  docume ntation style
SHIFT LEFT 4 ty pes SUMMAR Y
• TDD :  by de v eloper s A TDD & BDD :  by user s • TDD & BDD  r equir e automation A TDD:  automation optional • TDD  not prior it iz ed A TDD & BDD: prior it y  by user • A TDD & BDD support  c ollabor ation • D  =   D e v elopment Automated tests ar e  NO T  the g oa l • GO AL : push  de f ect  curv e to  the le ft