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

Recently uploaded (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
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
 
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
 
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
 
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
 
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...
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

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