SlideShare a Scribd company logo
1 of 9
Test-driven development
        with Java




                Edouard SWIAC
   Java Lab SF - javalabsf@googlegroups.com
Summary

• Principles
• Mocks and stubs
• TDD example
repeittion of very



                            What is TDD ?
short dev cycle of 3
steps

test come from story

refactor
changing source
without modifying
external functional    Software development process in 3 steps
behavior
because you have to design the
component before you code,




                                 TDD in short
and note design the component
while you code




                • Encourages simple design (Ken Beck)
                • Relies on automated unit testing
                • Builds a harness against software regression
although required,
dependencies and
                             Testing and
                            collaborators
collaborators needs to be
replace by somethin




               • Testing a unit of code is not testing its
                      collaborators
               • Collaborators have to be reproduced and
                      controlled to produce expected results so
                      tests can run => enter mocks !
Stubs and mocks                   stub on existing code
                                       or yet to be code

                                       mock help to test
                                       behavior




• A stub (or method stub) returns
  programmed results when called
• A mock (or mock object) mimics a real
  object. It has the same interface as the real
  objects it mimics.
• Mocks methods can be stubbed
TDD in action


• Demo !
More information

• Article: Mocks aren’t stubs (M. Fowler)
• Wikipedia: TDD
• Agile manifesto
Thank you !


• Questions ?
• Java lab mailing list:
  javalabsf@googlegroups.com

More Related Content

More from javalabsf (7)

Google App Engine & GWT
Google App Engine & GWTGoogle App Engine & GWT
Google App Engine & GWT
 
My First Android Application
My First Android ApplicationMy First Android Application
My First Android Application
 
GWT
GWTGWT
GWT
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Create a sexy Android application
 Create a sexy Android application Create a sexy Android application
Create a sexy Android application
 
My First Android Application
My First Android ApplicationMy First Android Application
My First Android Application
 
Déploiement d'applications Java EE
Déploiement d'applications Java EEDéploiement d'applications Java EE
Déploiement d'applications Java EE
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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...
 
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...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Test Driven Development with Java

  • 1. Test-driven development with Java Edouard SWIAC Java Lab SF - javalabsf@googlegroups.com
  • 2. Summary • Principles • Mocks and stubs • TDD example
  • 3. repeittion of very What is TDD ? short dev cycle of 3 steps test come from story refactor changing source without modifying external functional Software development process in 3 steps behavior
  • 4. because you have to design the component before you code, TDD in short and note design the component while you code • Encourages simple design (Ken Beck) • Relies on automated unit testing • Builds a harness against software regression
  • 5. although required, dependencies and Testing and collaborators collaborators needs to be replace by somethin • Testing a unit of code is not testing its collaborators • Collaborators have to be reproduced and controlled to produce expected results so tests can run => enter mocks !
  • 6. Stubs and mocks stub on existing code or yet to be code mock help to test behavior • A stub (or method stub) returns programmed results when called • A mock (or mock object) mimics a real object. It has the same interface as the real objects it mimics. • Mocks methods can be stubbed
  • 8. More information • Article: Mocks aren’t stubs (M. Fowler) • Wikipedia: TDD • Agile manifesto
  • 9. Thank you ! • Questions ? • Java lab mailing list: javalabsf@googlegroups.com

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n