TDD	  OUTSIDE-­‐IN	  Daniel	  Kolman	  @kolman	  blog.kolman.cz	                   www.vendavo.cz	  
UNIT	  TESTS	  ARE	  	               NOT	  ABOUT	  	              FINDING	  BUGS	  …so	  what	  they	  are	          about...
BOTTOM-­‐UP	      vs.	  OUTSIDE-­‐IN	                There	  are	  two	  styles	                of	  wriXng	  programs	  
BOTTOM-­‐UP	                        You	  can	  write	                    program	  starXng	  with	                     th...
BOTTOM-­‐UP	     E.g.	  you	  start	  with	  database	  and	  data	  access	  code	  and	  conXnue	  up	  to	             ...
OUTSIDE-­‐IN	                 Or	  you	  can	  start	  with	  UI	                  or	  some	  business	  logic,	         ...
OUTSIDE-­‐IN	   …because	  the	  low-­‐level	  details	  have	  no	     business	  value	         hCp://indeb^atshortbadte...
OUTSIDE-­‐IN	   When	  wriXng	  program	   outside-­‐in,	  you	  need	  to	    replace	  the	  low-­‐level	  code	  with	 ...
So	  we	  have	  seen	  in	  demo	  how	  to	  write	  program	  from	    tests	  and	  we	  may	  now	         understand...
EXTERNAL	  QUALITY	         vs.	  INTERNAL	  QUALITY	                  First,	  we	  need	  to	  have	  a	                ...
EXTERNAL	  QUALITY	  how	  well	  the	  system	  meets	  the	  needs	  of	  its	  customers	  and	  users	  	  	  (is	  it...
INTERNAL	  QUALITY	  how	  well	  it	  meets	  the	  needs	  of	  its	  developers	  and	  administrators	  	  	  (is	  it...
UNIT	  TEST	                    Test	  Unit	  test	  execute	  the	   object	  in	  isolaXon,	          mocking	  all	    ...
Of	  course	  nothing!	             USER	      Because	  users	  execute	                        the	  applicaXon	  like	 ...
There	  is	  a	  great	  book	     on	  this	  topic…	  
…and	  it	  contains	  this	  charts,	                                                explaining	  what	  kind	  of	  feed...
Which	  means	     that…	               UNIT	  TESTS	  ARE	  	                NOT	  ABOUT	  	               FINDING	  BUGS...
UNIT	  TESTS	  ARE	  	                               DESIGN	  TOOL	                                                       ...
EASY	  TO	  TEST	            =	  WELL	  DESIGNED	  
HARD	  TO	  TEST	            =	  BADLY	  DESIGNED	                …because	  the	  unit	  tests	               tell	  us	 ...
Therefore,	  if	  you	  want	  to	  write	  unit	          tests…	              FIX	  CODE	  FIRST!	                      ...
It	  makes	  no	  sense	  to	         unit	  test	  this:	                                                  …without	  try...
Odkazy	  k	  přednášce	  najdete	  na	  hCp://blog.kolman.cz	      Because…	                 UNIT	  TESTS	  ARE	  	       ...
Upcoming SlideShare
Loading in …5
×

TDD Outside-In

1,215 views

Published on

Commented slides for my WebExpo and JUG Ostrava talk. See full recording here: http://vimeo.com/51208668

Published in: Technology
1 Comment
4 Likes
Statistics
Notes
No Downloads
Views
Total views
1,215
On SlideShare
0
From Embeds
0
Number of Embeds
30
Actions
Shares
0
Downloads
5
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide

TDD Outside-In

  1. 1. TDD  OUTSIDE-­‐IN  Daniel  Kolman  @kolman  blog.kolman.cz   www.vendavo.cz  
  2. 2. UNIT  TESTS  ARE     NOT  ABOUT     FINDING  BUGS  …so  what  they  are   about?   hCp://www.flickr.com/photos/rupert_brun/6658715247  
  3. 3. BOTTOM-­‐UP   vs.  OUTSIDE-­‐IN   There  are  two  styles   of  wriXng  programs  
  4. 4. BOTTOM-­‐UP   You  can  write   program  starXng  with   the  low-­‐level  code  
  5. 5. BOTTOM-­‐UP   E.g.  you  start  with  database  and  data  access  code  and  conXnue  up  to   the  UI   UI     Controllers   Domain  Model   Data  Access   DB  Schema  
  6. 6. OUTSIDE-­‐IN   Or  you  can  start  with  UI   or  some  business  logic,   postponing  the  low-­‐level   details  unXl  really   necessary…  
  7. 7. OUTSIDE-­‐IN   …because  the  low-­‐level  details  have  no   business  value   hCp://indeb^atshortbadteeth.wordpress.com/2012/01/20/hello-­‐goals-­‐for-­‐a-­‐fortnight-­‐thursday-­‐results-­‐for-­‐challenge-­‐1-­‐and-­‐new-­‐goal/  
  8. 8. OUTSIDE-­‐IN   When  wriXng  program   outside-­‐in,  you  need  to   replace  the  low-­‐level  code  with  mocks  –  it  was   not  wriCen  yet   See  the  video   recording  for  demo   how  to  do  it  
  9. 9. So  we  have  seen  in  demo  how  to  write  program  from   tests  and  we  may  now   understand  that…   UNIT  TESTS  ARE     NOT  (just)  ABOUT     FINDING  BUGS   …but  why?  And  what   they  are  about?   hCp://www.flickr.com/photos/rupert_brun/6658715247  
  10. 10. EXTERNAL  QUALITY   vs.  INTERNAL  QUALITY   First,  we  need  to  have  a   look  at  two  kinds  of  quality   in  computer  sofware  
  11. 11. EXTERNAL  QUALITY  how  well  the  system  meets  the  needs  of  its  customers  and  users      (is  it  funcXonal,  reliable,  available,  responsive...)   hCp://www.youtube.com/watch?v=SLikJ1c53wc  
  12. 12. INTERNAL  QUALITY  how  well  it  meets  the  needs  of  its  developers  and  administrators      (is  it  easy  to  understand,  easy  to  change...)  
  13. 13. UNIT  TEST   Test  Unit  test  execute  the   object  in  isolaXon,   mocking  all   dependencies…   …but  what  can  this   test  tell  us  about   external  quality?  
  14. 14. Of  course  nothing!   USER   Because  users  execute   the  applicaXon  like  this:  User   And  this  is  how  end-­‐ to-­‐end  test  works.  
  15. 15. There  is  a  great  book   on  this  topic…  
  16. 16. …and  it  contains  this  charts,   explaining  what  kind  of  feedback   is  provided  by  different  kinds  of  Unit  test  tells  us  a  lot   tests   about  the  internal  quality  of  the  code…   …while  end-­‐to-­‐end  test   provides  a  lot  of  feedback   about  the  external  quality   of  the  app  
  17. 17. Which  means   that…   UNIT  TESTS  ARE     NOT  ABOUT     FINDING  BUGS   …because…   hCp://www.flickr.com/photos/rupert_brun/6658715247  
  18. 18. UNIT  TESTS  ARE     DESIGN  TOOL   …that  helps  keeping   the  code  clean  and   maintainable  hCp://www.flickr.com/photos/shelfappeal/4531230129  
  19. 19. EASY  TO  TEST   =  WELL  DESIGNED  
  20. 20. HARD  TO  TEST   =  BADLY  DESIGNED   …because  the  unit  tests   tell  us  a  lot  about  internal   quality  of  the  code  
  21. 21. Therefore,  if  you  want  to  write  unit   tests…   FIX  CODE  FIRST!   Otherwise  you  will  spend  ages   wriXng  terrible,  ugly  and  long   unit  tests,  just  to  find  out  that   the  internal  quality  of  the  code   is  bad  
  22. 22. It  makes  no  sense  to   unit  test  this:   …without  trying  to   improve  the  internal   design   hCp://www.flickr.com/photos/daveparker/28335459  
  23. 23. Odkazy  k  přednášce  najdete  na  hCp://blog.kolman.cz   Because…   UNIT  TESTS  ARE     DESIGN  TOOL   Thank  you!  Daniel  Kolman  @kolman  blog.kolman.cz   www.vendavo.cz  

×