SlideShare ist ein Scribd-Unternehmen logo
1 von 23
TDD	
  OUTSIDE-­‐IN	
  

Daniel	
  Kolman	
  
@kolman	
  
blog.kolman.cz	
                   www.vendavo.cz	
  
UNIT	
  TESTS	
  ARE	
  	
  
             NOT	
  ABOUT	
  	
  
            FINDING	
  BUGS	
  
…so	
  what	
  they	
  are	
  
        about?	
  


                                 hCp://www.flickr.com/photos/rupert_brun/6658715247	
  
BOTTOM-­‐UP	
  
    vs.	
  
OUTSIDE-­‐IN	
  
              There	
  are	
  two	
  styles	
  
              of	
  wriXng	
  programs	
  
BOTTOM-­‐UP	
  

                      You	
  can	
  write	
  
                  program	
  starXng	
  with	
  
                   the	
  low-­‐level	
  code	
  
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	
  
OUTSIDE-­‐IN	
  
               Or	
  you	
  can	
  start	
  with	
  UI	
  
                or	
  some	
  business	
  logic,	
  
               postponing	
  the	
  low-­‐level	
  
                      details	
  unXl	
  really	
  
                         necessary…	
  
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/	
  
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	
  
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	
  
EXTERNAL	
  QUALITY	
  
       vs.	
  
INTERNAL	
  QUALITY	
  
                First,	
  we	
  need	
  to	
  have	
  a	
  
              look	
  at	
  two	
  kinds	
  of	
  quality	
  
                 in	
  computer	
  sofware	
  
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	
  
INTERNAL	
  QUALITY	
  
how	
  well	
  it	
  meets	
  the	
  needs	
  of	
  its	
  developers	
  
and	
  administrators	
  	
  
	
  
(is	
  it	
  easy	
  to	
  understand,	
  easy	
  to	
  change...)	
  
UNIT	
  TEST	
  


                  Test	
  

Unit	
  test	
  execute	
  the	
  
 object	
  in	
  isolaXon,	
  
        mocking	
  all	
  
  dependencies…	
  
                                                    …but	
  what	
  can	
  this	
  
                                                     test	
  tell	
  us	
  about	
  
                                                     external	
  quality?	
  
Of	
  course	
  nothing!	
  
           USER	
      Because	
  users	
  execute	
  
                      the	
  applicaXon	
  like	
  this:	
  


User	
  




                          And	
  this	
  is	
  how	
  end-­‐
                           to-­‐end	
  test	
  works.	
  
There	
  is	
  a	
  great	
  book	
  
   on	
  this	
  topic…	
  
…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	
  
Which	
  means	
  
   that…	
  




             UNIT	
  TESTS	
  ARE	
  	
  
              NOT	
  ABOUT	
  	
  
             FINDING	
  BUGS	
  
      …because…	
  




                               hCp://www.flickr.com/photos/rupert_brun/6658715247	
  
UNIT	
  TESTS	
  ARE	
  	
  
                             DESIGN	
  TOOL	
  
                                                        …that	
  helps	
  keeping	
  
                                                        the	
  code	
  clean	
  and	
  
                                                           maintainable	
  




hCp://www.flickr.com/photos/shelfappeal/4531230129	
  
EASY	
  TO	
  TEST	
  
          =	
  
WELL	
  DESIGNED	
  
HARD	
  TO	
  TEST	
  
          =	
  
BADLY	
  DESIGNED	
  
              …because	
  the	
  unit	
  tests	
  
             tell	
  us	
  a	
  lot	
  about	
  internal	
  
                   quality	
  of	
  the	
  code	
  
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	
  
It	
  makes	
  no	
  sense	
  to	
  
       unit	
  test	
  this:	
  




                                                …without	
  trying	
  to	
  
                                               improve	
  the	
  internal	
  
                                                     design	
  




                                       hCp://www.flickr.com/photos/daveparker/28335459	
  
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	
  

Weitere ähnliche Inhalte

Ähnlich wie TDD Outside-In

Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)
Babul Mirdha
 
Test Essentials @mdevcon 2012
Test Essentials @mdevcon 2012Test Essentials @mdevcon 2012
Test Essentials @mdevcon 2012
Maxim Zaks
 
Reverse engineering
Reverse engineeringReverse engineering
Reverse engineering
Saswat Padhi
 

Ähnlich wie TDD Outside-In (20)

Introduction to Unit Testing
Introduction to Unit TestingIntroduction to Unit Testing
Introduction to Unit Testing
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
 
Test Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEMTest Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEM
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)
 
Test Driven Development in AEM/CQ5
Test Driven Development in AEM/CQ5Test Driven Development in AEM/CQ5
Test Driven Development in AEM/CQ5
 
Understanding Unit Testing
Understanding Unit TestingUnderstanding Unit Testing
Understanding Unit Testing
 
TDD - Seriously, try it! - Opensouthcode
TDD - Seriously, try it! - OpensouthcodeTDD - Seriously, try it! - Opensouthcode
TDD - Seriously, try it! - Opensouthcode
 
Test Essentials @mdevcon 2012
Test Essentials @mdevcon 2012Test Essentials @mdevcon 2012
Test Essentials @mdevcon 2012
 
xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012
 
Unit Testing & Test Driven Development
Unit Testing & Test Driven DevelopmentUnit Testing & Test Driven Development
Unit Testing & Test Driven Development
 
Coding Naked
Coding NakedCoding Naked
Coding Naked
 
Development without Testers: Myth or Real Option? (ConfeT&QA conference)
Development without Testers: Myth or Real Option? (ConfeT&QA conference)Development without Testers: Myth or Real Option? (ConfeT&QA conference)
Development without Testers: Myth or Real Option? (ConfeT&QA conference)
 
Reverse engineering
Reverse engineeringReverse engineering
Reverse engineering
 
Development without Testers: Myth or Real Option?
Development without Testers: Myth or Real Option?Development without Testers: Myth or Real Option?
Development without Testers: Myth or Real Option?
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Ian Cooper webinar for DDD Iran: Kent beck style tdd   seven years afterIan Cooper webinar for DDD Iran: Kent beck style tdd   seven years after
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
 
TDD in the Web with Python and Django
TDD in the Web with Python and DjangoTDD in the Web with Python and Django
TDD in the Web with Python and Django
 
Debugging
DebuggingDebugging
Debugging
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

TDD Outside-In

  • 1. TDD  OUTSIDE-­‐IN   Daniel  Kolman   @kolman   blog.kolman.cz   www.vendavo.cz  
  • 2. UNIT  TESTS  ARE     NOT  ABOUT     FINDING  BUGS   …so  what  they  are   about?   hCp://www.flickr.com/photos/rupert_brun/6658715247  
  • 3. BOTTOM-­‐UP   vs.   OUTSIDE-­‐IN   There  are  two  styles   of  wriXng  programs  
  • 4. BOTTOM-­‐UP   You  can  write   program  starXng  with   the  low-­‐level  code  
  • 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. OUTSIDE-­‐IN   Or  you  can  start  with  UI   or  some  business  logic,   postponing  the  low-­‐level   details  unXl  really   necessary…  
  • 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. 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. 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. EXTERNAL  QUALITY   vs.   INTERNAL  QUALITY   First,  we  need  to  have  a   look  at  two  kinds  of  quality   in  computer  sofware  
  • 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. INTERNAL  QUALITY   how  well  it  meets  the  needs  of  its  developers   and  administrators       (is  it  easy  to  understand,  easy  to  change...)  
  • 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. Of  course  nothing!   USER   Because  users  execute   the  applicaXon  like  this:   User   And  this  is  how  end-­‐ to-­‐end  test  works.  
  • 15. There  is  a  great  book   on  this  topic…  
  • 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. Which  means   that…   UNIT  TESTS  ARE     NOT  ABOUT     FINDING  BUGS   …because…   hCp://www.flickr.com/photos/rupert_brun/6658715247  
  • 18. UNIT  TESTS  ARE     DESIGN  TOOL   …that  helps  keeping   the  code  clean  and   maintainable   hCp://www.flickr.com/photos/shelfappeal/4531230129  
  • 19. EASY  TO  TEST   =   WELL  DESIGNED  
  • 20. HARD  TO  TEST   =   BADLY  DESIGNED   …because  the  unit  tests   tell  us  a  lot  about  internal   quality  of  the  code  
  • 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. It  makes  no  sense  to   unit  test  this:   …without  trying  to   improve  the  internal   design   hCp://www.flickr.com/photos/daveparker/28335459  
  • 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