Atdd for web apps
Upcoming SlideShare
Loading in...5
×
Like this presentation? Why not share!

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
510
On Slideshare
510
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
3
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Acceptance  Test  Driven  Development  for  Web  Apps  Eemeli  Kantola  15.6.2012  
  • 2. ›  Eemeli  Kantola   ›  Web  dev,  consulting,  About  me   lean/agile  enthusiasm   ›  Customer  projects   ›  Lecturing  
  • 3. Futurice  in  brief   TAMPERE   HELSINKI   LONDON   BERLIN   DÜSSELDORF   1   Founded  in   150   2000  
  • 4. We  offer  tailored  solutions   done  with     agile  methods.  
  • 5. Ask  why!  
  • 6. “Its  not  enough  to  know  how  to  do  things  –  you  must  know  why  you  do   them.”   –  Harvey  Mackay  
  • 7. …and  doing  stuff  is  ~2x  more  efficient   if  you  know  why  
  • 8. Why  am  I  here  
  • 9. I  like  to  create  awesome  web  apps  for   (human)  end  users  
  • 10. Awesome:  getting  people  where  they  need  to  be  faster  than  they  would  get   there  without  
  • 11. ›  It’s  kewl   ›  HTML5  is  bestest  Web,  why?   ›  Everyone’s  doing  it,  so   why  not?  
  • 12. Building  on  web  is  in  many  cases  more   awesome  than  alternatives  when   building  sw  for  human  end  users  
  • 13. ›  Single  (HTML)  page  load   ›  Using  «Hypermedia  APIs»  Web  apps?   (a.k.a.  RESTful  etc.  backend)   ›  Suck  usually  less  than  other   approaches  when  done  right  
  • 14. ›  Involving  humans  less  trivial,  Human  end   i.e.  more  interesting   users?   ›  Interdisciplinary  approaches   necessary  
  • 15. Ok,  fine.  How?  
  • 16. ATDD  
  • 17. ATDD,   »  Test  Driven  Requirements  (TDR)  a.k.a.   »  Functional  Test  Driven  Development  (FTDD)  (or  related  to)   »  Behavior  Driven  Development  (BDD)   »  Story  Test  Driven  Development   »  Executable  Requirements   »  End-­‐to-­‐End  Test  Driven  Development   »  Customer  Test  Driven  Development   »  Business-­‐Facing  Test  Driven  Development   »  Specification  by  Example   »  ...  15.6.2012   Futurice   21  
  • 18. Acceptance  test?   wat  
  • 19. Warning:  not  to  be  confused  with  User  Acceptance  Tests  (UAT)  here   –  although  both  are  related…  
  • 20. “Begin  with  the  end  in  mind”  –  Stephen  R.  Covey:  The  7  Habits  of  Highly  Effective  People  
  • 21. ATDD:  “The  practice  of  expressing   functional  story  requirements  as  concrete  examples  or  expectations  prior   to  story  development”   –  Jennitta  Andrea,  http://www.stickyminds.com/sitewide.asp?Function=edetail&ObjectId=16315      
  • 22. “BDD  (and  ATDD  as  well)  is  what  TDD   was  supposed  to  be”   –  Franz  See  in  BehaviourDrivenDevelopment  Google  Group,  2011-­‐01-­‐31  
  • 23. ›  One  method  in  toolbox   ATDD   among  others  Disclaimers   ›  Lots  of  skills  and  other   practices  needed,  too  
  • 24. ›  Crystallize  acceptance   criteria:  get  a  shared   understanding  of  reqs   and  def.  of  done  [1]   Goals   ›  Win  the  bug  battle  with   complicated  systems   [2]:  early  regression   detection  [1]  E.  Hendrickson,  http://testobsessed.com/blog/2008/12/08/acceptance-­‐test-­‐driven-­‐development-­‐atdd-­‐an-­‐overview    [2]  J.  E.  Boal,  http://testdrivendeveloper.com/2011/12/27/AutomatedTestsAreTheKeyToScalingAgile.aspx  
  • 25. ›  Minimize  unnecessary  work   (=  less  YAGNI)   ›  Solid  regression  tests  enable   Positive  side   incremental  development   effects   ›  Feels  great  every  time  when   a  bug  that  would’ve  gone  to   prod  was  caught  by  tests  [2]   ›  Enables  cont.  deployment    [2]  J.  E.  Boal,  http://testdrivendeveloper.com/2011/12/27/AutomatedTestsAreTheKeyToScalingAgile.aspx  
  • 26. ›  Acceptance  tests  =   executable,  up-­‐to-­‐date  docs   Positive  side   ›  Enriched  tester  role:  get  rid   effects   of  most  mechanical  work   (cont.)  [3]   ›  Highly  testable  system   ›  Trustworthy  specifications    [3]  J.    Andrea,  http://www.stickyminds.com/sitewide.asp?Function=edetail&ObjectId=16315      
  • 27. ›  Too  difficult:  needs  skills,   collaboration,  and  discipline;   or  no  tools  exist   ›  Not  feasible  to  automate   everything  (in  practice)   Why  not?   ›  Doing  small,  prototype,   unimportant,  simple  stuff   ›  Discovery,  spikes  [4]   ›  Initial  setup  overhead   ›  «I  don’t  know  why»    [4]  Liz  Keogh,  http://lizkeogh.com/2012/01/30/the-­‐real-­‐cost-­‐of-­‐change    
  • 28. Cool.  What  about  something  concrete?  
  • 29. Steps   Implement:  hammer  the   Design  how  to  fulfill   keyboard  until  all  tests   the  requirement   pass  (incl.  other  tests)   Write   Story   Design   Code   tests   Find  out  most  important   Formulate  test  cases,   thing  to  do,  write  a  user  story   most  probable  path  first  15.6.2012   Futurice   33  
  • 30. Focus  now:  Formulate  test  cases   –  on  paper  and  then  in  code  
  • 31. Hands  on  
  • 32. Demo  App:  Stopwatch  
  • 33. ›  have  a  timer  display  with   zeroed  time  and  a  start  btn   What  do  you   ›  start  on  button  click  need  for  one?     ›  if  started,  stop  when  button   is  clicked  again   It  should…   ›  update  the  timer  seconds   and  fractions  when  running  
  • 34. 1)  Web  browser  of  your  choice   Tech  stack   2)  Jasmine  BDD  for  this  session   3)  CoffeeScript  (optional)   4)  jQuery  (optional)  
  • 35. Getting   »  Download  and  unzip  Jasmine  BDD  started   standalone  to  a  working  dir   ›  Try  it:  open  SpecRunner.html  in  browser   ›  Playing  around  a  bit   ›  Hack  Jasmine  to  make  it  better  (optional)   »  Write  specs  in  code  15.6.2012   Futurice   41  
  • 36. Sources:https://github.com/ekantola/atdd-­‐for-­‐web-­‐apps  
  • 37. Would  also  be   ›  continue  running  from   where  it  was  stopped  last   pretty  nice  if   ›  remember  the  last  stopped   the  timer   time  across  app  reloads   could…   ›  etc…  
  • 38. More  pointers  and  ideas  
  • 39. Autom.  &   Business-­‐facing   Manual   Agile  Testing   Manual   Protos   Quadrants   Func.  Tests   Scenarios   Expl.  Testing     Simulations   Acceptance   Usability  Tests   Alpha/Beta   From    Crispin&Gregory,     Tests(*   UAT   Agile  Testing  book     Examples    Original  idea:  Brian  Marick   Perf  &  Load,   Unit  Tests   Security,   Component   “-­‐ility”   Tests   Testing   Automated   Tech-­‐facing   Tools   46  
  • 40. Autom.  &   Business-­‐facing   Manual   Agile  Testing   Manual   Protos   Quadrants   Func.  Tests   Scenarios   Expl.  Testing     Simulations   Acceptance   Usability  Tests   Alpha/Beta   From    Crispin&Gregory,     Tests(*   UAT   Agile  Testing  book     Examples    Original  idea:  Brian  Marick   Perf  &  Load,   Unit  Tests   Security,   Component   “-­‐ility”   Tests   Testing   *)  Originally,  Story  Tests   Automated   Tech-­‐facing   Tools   47  
  • 41. Some  other   »  Selenium   »  JBehave  tools  to   »  Robot  Framework   »  Rspec  help  writing   »  FitNesse   »  Cucumber  &  running   »  Poltergeist   »  Expect  tests   »  Watir/Watij   »  easyb   »  Canoo  WebTest   »  Slim   »  StoryTeller   »  Specflow   »  Screw.Unit   »  QUnit+Pavlov  15.6.2012   Futurice   48  
  • 42. Selenium  »  Automation  of  browsers   ›  E.g.  for  testing  purposes,  or  for  repetitive  admin  tasks  »  Selenium  IDE  for  recording  scripts  »  Scaling  and  distributing  test  running  »  Java-­‐based,  with  wide  support  for  other  langs  &  testing  frameworks  16.6.2012   Futurice   49  
  • 43. Cucumber  BDD  »  Automation  of  browsers  »  Describing  behavior  in  plain,  human  readable  text  (Given-­‐When-­‐Then)   ›  Higher  level  abstraction  for  tests  »  Ruby-­‐based,  but  bindings  for  other  langs  exist  16.6.2012   Futurice   50  
  • 44. Given-­‐When-­‐Then  (GWT)  Example  of  a  popular  approach:  »  Given  the  shopping  cart  is  visible  and  has  three  items  in  it,  »  When  the  user  clicks  an  item’s  trashcan  icon,  »  Then  the  item  should  disappear  from  the  list  and  a  notification  should  be   shown  with  the  item’s  name  and  an  “Undo”  link.  15.6.2012   Futurice   51  
  • 45. Robot  Framework  »  Generic  test  automation  framework  for  various  domains   ›  Web  part  backed  by  e.g.  Selenium,  but  also  Java  GUI,  SSH,  running  processes...  »  Tabular  test  data  syntax  »  Extensible  with  Python/Java  16.6.2012   Futurice   53  
  • 46. Conclusions  
  • 47. ›  Easy  to  start  with  in  web,   powerful  tools  exist  ›  Longer  projects:  no  time  not   to  automate  and  maintain   tests  
  • 48. Thanks!  Contact:  @ekantola  github.com/ekantola