SlideShare uma empresa Scribd logo
1 de 31
Baixar para ler offline
TDD (with FLOW3)
  Karsten Dambekalns <karsten@typo3.org>
      Robert Lemke <robert@typo3.org>




                                           Inspiring people to
                                           share
What?
   Why?
  How?
Integrate!
             Inspiring people to
             share
Test first,
  code later
Test first, code later
  Write tests for all your code

 •   New features come with a test

 •   Bugfixes come with a test

  Write tests before your code

 •   Adding a feature means adding a test first

 •   Fixing a bug means writing a test first




                                                 Inspiring people to
                                                 share
Unit tests
  Unit tests are small programs that test your code

  They check

 •   the result of methods against expected values

 •   whether methods are (not) called as expected

  A test should

 •   be well-named

 •   check only one assertion



                                                  Inspiring people to
                                                  share
Good tests
 Should be...

 •   automated

 •   self-contained

 •   repeatable

 •   thorough

 •   small

 •   talk about the domain



                             Inspiring people to
                             share
Unit tests
  Unit tests are usually run with a test runner

  The xUnit family is most widespread

  PHPUnit does the job for PHP




                                                  Inspiring people to
                                                  share
Tests aren’t
   the goal
But you said...
They make you feel good
They make you feel good
  The tests make you

 •   focus on your task

 •   code exactly what you need

 •   think from the outside

 •   a better programmer*

  So what the tests do for you is the key

                               * decoupling helps with testing,
                               decoupled code is easier to maintain,
                               easier is better - q.e.d.


                                                   Inspiring people to
                                                   share
Reasons for TDD
 Feel more comfortable

 •   Build confidence in your code

 •   Reduce fear of change

 (Good) tests are (good) documentation

 Acts as safety net

 •   Regression testing built in

 •   Helps with refactoring



                                         Inspiring people to
                                         share
D for Design
 Writing tests first is likely to improve your code

 Constant refactoring keeps code clean

 Unit testing ensure decoupling

 You only code what is really needed




                                                     Inspiring people to
                                                     share
TDD in Practice

            Inspiring people to
            share
The Mantra




             Inspiring people to
             share
The Mantra
           Design



   Test                 Test




          Implement



                      Inspiring people to
                      share
More testing
 Sometimes you need to test interaction with external systems,
 like database access

 A test should be small, encapsulated, stand-alone

 So how do you test database access?




                                                Inspiring people to
                                                share
Mocks & stubs
 Mock objects allow you to use fake objects instead of real
 implementations

 Stubs can be used to return hard-coded results

 Using them is actually (somewhat) easy with PHPUnit




                                                  Inspiring people to
                                                  share
Saving in TYPO3CR
 Assumptions / Background

 •   The Session object has a save() method

 •   It uses a Storage_Backend implementation to do the work

 •   That implementation has methods like addNode(),
     updateNode() and deleteNode()

 You need to make sure those are used when calling save()




                                                Inspiring people to
                                                share
No FLOW3?
 No TDD!
No TDD without FLOW3
 Without Dependency Injection you cannot really do unit testing




                                                 Inspiring people to
                                                 share
Dependencies
 Problem: Classes explicitly refer to other classes:




                                                       Inspiring people to
                                                       share
Dependencies
 Try to test this class:




                           Inspiring people to
                           share
Dependencies
 Unit Testing: You want to test a small unit

 You don't want to test

 •   The Simple File Logger

 •   The Card Repository




                                               Inspiring people to
                                               share
Dependencies
 Unit Testing: You want to test a small unit

 You want to test

 •   if the action returns a string representation of the
     random card it gets from the repository




                                                    Inspiring people to
                                                    share
Dependency Injection
 A class doesn't ask for the instance of another class but gets it
 injected

 This methodology is referred to as the quot;Hollywood Principlequot;:
 quot;Don't call us, we'll call youquot;

 Enforces loose coupling and high cohesion

 Allows you to mock collaborators

 Makes you a better programmer




                                                   Inspiring people to
                                                   share
Questions!
Links & Literature
   Test-Driven Development By Example
   Kent Beck, Addison-Wesley


   Continuous Integration – Improving Software Quality and
   Reducing Risk
   Paul M. Duvall, Addison-Wesley

   xUnit Test Patterns – Refactoring Test Code
   Gerard Meszaros, Addison-Wesley




                                                 Inspiring people to
                                                 share
Links & Literature
  FLOW3
  http://flow3.typo3.org/

  PHPUnit
  http://www.phpunit.de/

  Hudson CI-Server
  https://hudson.dev.java.net/

  TYPO3 Forge
  http://forge.typo3.org/




                                 Inspiring people to
                                 share
TDD (with FLOW3)

Mais conteúdo relacionado

Mais procurados

Mais procurados (10)

Agile and ATDD the perfect couple
Agile and ATDD the perfect coupleAgile and ATDD the perfect couple
Agile and ATDD the perfect couple
 
Journey of atdd
Journey of atddJourney of atdd
Journey of atdd
 
ATDD in Practice
ATDD in PracticeATDD in Practice
ATDD in Practice
 
Tdd and-design-draft
Tdd and-design-draftTdd and-design-draft
Tdd and-design-draft
 
eclipse
eclipseeclipse
eclipse
 
Scrum and Test-driven development
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and 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
 
Agile Test Driven Development
Agile Test Driven DevelopmentAgile Test Driven Development
Agile Test Driven Development
 
ATDD in practice
ATDD in practiceATDD in practice
ATDD in practice
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 

Destaque

pathology practical original slide NO2
pathology practical original slide NO2pathology practical original slide NO2
pathology practical original slide NO2kushrokz
 
pathology practical original slide NO4
pathology practical original slide NO4pathology practical original slide NO4
pathology practical original slide NO4kushrokz
 
pathology practical original slide NO7
pathology practical original slide NO7pathology practical original slide NO7
pathology practical original slide NO7kushrokz
 
Mind maps pathology_neoplastic_proliferative_hematopoietic_lymphoid
Mind maps pathology_neoplastic_proliferative_hematopoietic_lymphoidMind maps pathology_neoplastic_proliferative_hematopoietic_lymphoid
Mind maps pathology_neoplastic_proliferative_hematopoietic_lymphoidNicolas Lévy
 
pathology practical original slide NO6
pathology practical original slide NO6pathology practical original slide NO6
pathology practical original slide NO6kushrokz
 
5กระบวนการวิทยาศาสตร์(สมเกียรติ วิชาการ)
5กระบวนการวิทยาศาสตร์(สมเกียรติ วิชาการ)5กระบวนการวิทยาศาสตร์(สมเกียรติ วิชาการ)
5กระบวนการวิทยาศาสตร์(สมเกียรติ วิชาการ)Rank Saharath
 
NEUROPATHOLOGY LECTURE 2009*
NEUROPATHOLOGY LECTURE 2009*NEUROPATHOLOGY LECTURE 2009*
NEUROPATHOLOGY LECTURE 2009*Michael Thomas
 
pathology practical original slide NO1
pathology practical original slide NO1pathology practical original slide NO1
pathology practical original slide NO1kushrokz
 
13 facial neuropathology
13 facial neuropathology13 facial neuropathology
13 facial neuropathologyEphrem Tamiru
 
B Cell Development
B Cell DevelopmentB Cell Development
B Cell Developmentraj kumar
 
8. Acute Lymphoblastic Leukemia
8. Acute Lymphoblastic Leukemia8. Acute Lymphoblastic Leukemia
8. Acute Lymphoblastic LeukemiaWhiteraven68
 
Acute lymphoid leukemia (case presentation)
Acute lymphoid leukemia (case presentation)Acute lymphoid leukemia (case presentation)
Acute lymphoid leukemia (case presentation)Dhritiman Chakrabarti
 
My Works About User Experience Study & Usability Test
My Works About User Experience Study & Usability TestMy Works About User Experience Study & Usability Test
My Works About User Experience Study & Usability TestRuby Kuo
 
I pad user group nov
I pad user group novI pad user group nov
I pad user group novJosh Allen
 

Destaque (20)

JavaScript for PHP Developers
JavaScript for PHP DevelopersJavaScript for PHP Developers
JavaScript for PHP Developers
 
pathology practical original slide NO2
pathology practical original slide NO2pathology practical original slide NO2
pathology practical original slide NO2
 
pathology practical original slide NO4
pathology practical original slide NO4pathology practical original slide NO4
pathology practical original slide NO4
 
pathology practical original slide NO7
pathology practical original slide NO7pathology practical original slide NO7
pathology practical original slide NO7
 
Mind maps pathology_neoplastic_proliferative_hematopoietic_lymphoid
Mind maps pathology_neoplastic_proliferative_hematopoietic_lymphoidMind maps pathology_neoplastic_proliferative_hematopoietic_lymphoid
Mind maps pathology_neoplastic_proliferative_hematopoietic_lymphoid
 
pathology practical original slide NO6
pathology practical original slide NO6pathology practical original slide NO6
pathology practical original slide NO6
 
5กระบวนการวิทยาศาสตร์(สมเกียรติ วิชาการ)
5กระบวนการวิทยาศาสตร์(สมเกียรติ วิชาการ)5กระบวนการวิทยาศาสตร์(สมเกียรติ วิชาการ)
5กระบวนการวิทยาศาสตร์(สมเกียรติ วิชาการ)
 
NEUROPATHOLOGY LECTURE 2009*
NEUROPATHOLOGY LECTURE 2009*NEUROPATHOLOGY LECTURE 2009*
NEUROPATHOLOGY LECTURE 2009*
 
pathology practical original slide NO1
pathology practical original slide NO1pathology practical original slide NO1
pathology practical original slide NO1
 
13 facial neuropathology
13 facial neuropathology13 facial neuropathology
13 facial neuropathology
 
B cell lymphoma
B cell lymphomaB cell lymphoma
B cell lymphoma
 
B Cell Development
B Cell DevelopmentB Cell Development
B Cell Development
 
8. Acute Lymphoblastic Leukemia
8. Acute Lymphoblastic Leukemia8. Acute Lymphoblastic Leukemia
8. Acute Lymphoblastic Leukemia
 
Acute lymphoid leukemia (case presentation)
Acute lymphoid leukemia (case presentation)Acute lymphoid leukemia (case presentation)
Acute lymphoid leukemia (case presentation)
 
Eco palsbg
Eco palsbgEco palsbg
Eco palsbg
 
Eco palsen
Eco palsenEco palsen
Eco palsen
 
My Works About User Experience Study & Usability Test
My Works About User Experience Study & Usability TestMy Works About User Experience Study & Usability Test
My Works About User Experience Study & Usability Test
 
Plumps for garbage
Plumps for garbagePlumps for garbage
Plumps for garbage
 
I pad user group nov
I pad user group novI pad user group nov
I pad user group nov
 
Water sadikov daniel
Water sadikov danielWater sadikov daniel
Water sadikov daniel
 

Semelhante a TDD (with FLOW3)

An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development CodeOps Technologies LLP
 
Unit testing
Unit testingUnit testing
Unit testingPiXeL16
 
Reduce Development Cost with Test Driven Development
Reduce Development Cost with Test Driven DevelopmentReduce Development Cost with Test Driven Development
Reduce Development Cost with Test Driven Developmentsthicks14
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)David Ehringer
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentDhaval Dalal
 
Automatic for the People
Automatic for the PeopleAutomatic for the People
Automatic for the PeopleAndy Zaidman
 
Beyond TDD: Enabling Your Team to Continuously Deliver Software
Beyond TDD: Enabling Your Team to Continuously Deliver SoftwareBeyond TDD: Enabling Your Team to Continuously Deliver Software
Beyond TDD: Enabling Your Team to Continuously Deliver SoftwareChris Weldon
 
Essential practices and thinking tools for Agile Adoption
Essential practices and thinking tools for Agile AdoptionEssential practices and thinking tools for Agile Adoption
Essential practices and thinking tools for Agile AdoptionSteven Mak
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionDionatan default
 
Agile Testing, Uncertainty, Risk, and Why It All Works
Agile Testing, Uncertainty, Risk, and Why It All WorksAgile Testing, Uncertainty, Risk, and Why It All Works
Agile Testing, Uncertainty, Risk, and Why It All WorksElisabeth Hendrickson
 
Journey's diary developing a framework using tdd
Journey's diary   developing a framework using tddJourney's diary   developing a framework using tdd
Journey's diary developing a framework using tddeduardomg23
 
DevOps interview questions and answers
DevOps interview questions and answersDevOps interview questions and answers
DevOps interview questions and answersHopeTutors1
 
DevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroDevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroPaul Boos
 
Testing Plug-in Architectures
Testing Plug-in ArchitecturesTesting Plug-in Architectures
Testing Plug-in ArchitecturesArie van Deursen
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven DevelopmentMichael Denomy
 
Introduction to test programming
Introduction to test programmingIntroduction to test programming
Introduction to test programmingopenfinanceDev
 
Exploratory Testing Explained
Exploratory Testing ExplainedExploratory Testing Explained
Exploratory Testing ExplainedTechWell
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flexmichael.labriola
 

Semelhante a TDD (with FLOW3) (20)

An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development
 
Unit testing
Unit testingUnit testing
Unit testing
 
Reduce Development Cost with Test Driven Development
Reduce Development Cost with Test Driven DevelopmentReduce Development Cost with Test Driven Development
Reduce Development Cost with Test Driven Development
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Automatic for the People
Automatic for the PeopleAutomatic for the People
Automatic for the People
 
Beyond TDD: Enabling Your Team to Continuously Deliver Software
Beyond TDD: Enabling Your Team to Continuously Deliver SoftwareBeyond TDD: Enabling Your Team to Continuously Deliver Software
Beyond TDD: Enabling Your Team to Continuously Deliver Software
 
Essential practices and thinking tools for Agile Adoption
Essential practices and thinking tools for Agile AdoptionEssential practices and thinking tools for Agile Adoption
Essential practices and thinking tools for Agile Adoption
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in Action
 
Writing Quality Code
Writing Quality CodeWriting Quality Code
Writing Quality Code
 
Agile Testing, Uncertainty, Risk, and Why It All Works
Agile Testing, Uncertainty, Risk, and Why It All WorksAgile Testing, Uncertainty, Risk, and Why It All Works
Agile Testing, Uncertainty, Risk, and Why It All Works
 
Agile Testing Overview
Agile Testing OverviewAgile Testing Overview
Agile Testing Overview
 
Journey's diary developing a framework using tdd
Journey's diary   developing a framework using tddJourney's diary   developing a framework using tdd
Journey's diary developing a framework using tdd
 
DevOps interview questions and answers
DevOps interview questions and answersDevOps interview questions and answers
DevOps interview questions and answers
 
DevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroDevOps - Boldly Go for Distro
DevOps - Boldly Go for Distro
 
Testing Plug-in Architectures
Testing Plug-in ArchitecturesTesting Plug-in Architectures
Testing Plug-in Architectures
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
Introduction to test programming
Introduction to test programmingIntroduction to test programming
Introduction to test programming
 
Exploratory Testing Explained
Exploratory Testing ExplainedExploratory Testing Explained
Exploratory Testing Explained
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 

Mais de Karsten Dambekalns

The Perfect Neos Project Setup
The Perfect Neos Project SetupThe Perfect Neos Project Setup
The Perfect Neos Project SetupKarsten Dambekalns
 
Sawubona! Content Dimensions with Neos
Sawubona! Content Dimensions with NeosSawubona! Content Dimensions with Neos
Sawubona! Content Dimensions with NeosKarsten Dambekalns
 
Deploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using SurfDeploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using SurfKarsten Dambekalns
 
Profiling TYPO3 Flow Applications
Profiling TYPO3 Flow ApplicationsProfiling TYPO3 Flow Applications
Profiling TYPO3 Flow ApplicationsKarsten Dambekalns
 
Using Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 FlowUsing Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 FlowKarsten Dambekalns
 
How Git and Gerrit make you more productive
How Git and Gerrit make you more productiveHow Git and Gerrit make you more productive
How Git and Gerrit make you more productiveKarsten Dambekalns
 
The agile future of a ponderous project
The agile future of a ponderous projectThe agile future of a ponderous project
The agile future of a ponderous projectKarsten Dambekalns
 
How Domain-Driven Design helps you to migrate into the future
How Domain-Driven Design helps you to migrate into the futureHow Domain-Driven Design helps you to migrate into the future
How Domain-Driven Design helps you to migrate into the futureKarsten Dambekalns
 
Content Repository, Versioning and Workspaces in TYPO3 Phoenix
Content Repository, Versioning and Workspaces in TYPO3 PhoenixContent Repository, Versioning and Workspaces in TYPO3 Phoenix
Content Repository, Versioning and Workspaces in TYPO3 PhoenixKarsten Dambekalns
 
Transparent Object Persistence (within FLOW3)
Transparent Object Persistence (within FLOW3)Transparent Object Persistence (within FLOW3)
Transparent Object Persistence (within FLOW3)Karsten Dambekalns
 
Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3Karsten Dambekalns
 
Implementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPImplementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPKarsten Dambekalns
 
Knowledge Management in der TYPO3 Community
Knowledge Management in der TYPO3 CommunityKnowledge Management in der TYPO3 Community
Knowledge Management in der TYPO3 CommunityKarsten Dambekalns
 
Implementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPImplementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPKarsten Dambekalns
 
A Content Repository for TYPO3 5.0
A Content Repository for TYPO3 5.0A Content Repository for TYPO3 5.0
A Content Repository for TYPO3 5.0Karsten Dambekalns
 
Introduction to Source Code Management
Introduction to Source Code ManagementIntroduction to Source Code Management
Introduction to Source Code ManagementKarsten Dambekalns
 

Mais de Karsten Dambekalns (20)

The Perfect Neos Project Setup
The Perfect Neos Project SetupThe Perfect Neos Project Setup
The Perfect Neos Project Setup
 
Sawubona! Content Dimensions with Neos
Sawubona! Content Dimensions with NeosSawubona! Content Dimensions with Neos
Sawubona! Content Dimensions with Neos
 
Deploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using SurfDeploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using Surf
 
Profiling TYPO3 Flow Applications
Profiling TYPO3 Flow ApplicationsProfiling TYPO3 Flow Applications
Profiling TYPO3 Flow Applications
 
Using Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 FlowUsing Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 Flow
 
i18n and L10n in TYPO3 Flow
i18n and L10n in TYPO3 Flowi18n and L10n in TYPO3 Flow
i18n and L10n in TYPO3 Flow
 
FLOW3-Workshop F3X12
FLOW3-Workshop F3X12FLOW3-Workshop F3X12
FLOW3-Workshop F3X12
 
Doctrine in FLOW3
Doctrine in FLOW3Doctrine in FLOW3
Doctrine in FLOW3
 
How Git and Gerrit make you more productive
How Git and Gerrit make you more productiveHow Git and Gerrit make you more productive
How Git and Gerrit make you more productive
 
The agile future of a ponderous project
The agile future of a ponderous projectThe agile future of a ponderous project
The agile future of a ponderous project
 
How Domain-Driven Design helps you to migrate into the future
How Domain-Driven Design helps you to migrate into the futureHow Domain-Driven Design helps you to migrate into the future
How Domain-Driven Design helps you to migrate into the future
 
Content Repository, Versioning and Workspaces in TYPO3 Phoenix
Content Repository, Versioning and Workspaces in TYPO3 PhoenixContent Repository, Versioning and Workspaces in TYPO3 Phoenix
Content Repository, Versioning and Workspaces in TYPO3 Phoenix
 
Transparent Object Persistence (within FLOW3)
Transparent Object Persistence (within FLOW3)Transparent Object Persistence (within FLOW3)
Transparent Object Persistence (within FLOW3)
 
Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3
 
Implementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPImplementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHP
 
Knowledge Management in der TYPO3 Community
Knowledge Management in der TYPO3 CommunityKnowledge Management in der TYPO3 Community
Knowledge Management in der TYPO3 Community
 
Unicode & PHP6
Unicode & PHP6Unicode & PHP6
Unicode & PHP6
 
Implementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPImplementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHP
 
A Content Repository for TYPO3 5.0
A Content Repository for TYPO3 5.0A Content Repository for TYPO3 5.0
A Content Repository for TYPO3 5.0
 
Introduction to Source Code Management
Introduction to Source Code ManagementIntroduction to Source Code Management
Introduction to Source Code Management
 

Último

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
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)wesley chun
 
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 2024The Digital Insurer
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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...Drew Madelung
 
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 organizationRadu Cotescu
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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 Takeoffsammart93
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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.pdfsudhanshuwaghmare1
 
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.pdfUK Journal
 
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...apidays
 
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 Processorsdebabhi2
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
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 CVKhem
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Último (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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)
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
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
 
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...
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
+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...
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

TDD (with FLOW3)

  • 1. TDD (with FLOW3) Karsten Dambekalns <karsten@typo3.org> Robert Lemke <robert@typo3.org> Inspiring people to share
  • 2. What? Why? How? Integrate! Inspiring people to share
  • 3. Test first, code later
  • 4. Test first, code later Write tests for all your code • New features come with a test • Bugfixes come with a test Write tests before your code • Adding a feature means adding a test first • Fixing a bug means writing a test first Inspiring people to share
  • 5. Unit tests Unit tests are small programs that test your code They check • the result of methods against expected values • whether methods are (not) called as expected A test should • be well-named • check only one assertion Inspiring people to share
  • 6. Good tests Should be... • automated • self-contained • repeatable • thorough • small • talk about the domain Inspiring people to share
  • 7. Unit tests Unit tests are usually run with a test runner The xUnit family is most widespread PHPUnit does the job for PHP Inspiring people to share
  • 8. Tests aren’t the goal
  • 10.
  • 11. They make you feel good
  • 12. They make you feel good The tests make you • focus on your task • code exactly what you need • think from the outside • a better programmer* So what the tests do for you is the key * decoupling helps with testing, decoupled code is easier to maintain, easier is better - q.e.d. Inspiring people to share
  • 13. Reasons for TDD Feel more comfortable • Build confidence in your code • Reduce fear of change (Good) tests are (good) documentation Acts as safety net • Regression testing built in • Helps with refactoring Inspiring people to share
  • 14. D for Design Writing tests first is likely to improve your code Constant refactoring keeps code clean Unit testing ensure decoupling You only code what is really needed Inspiring people to share
  • 15. TDD in Practice Inspiring people to share
  • 16. The Mantra Inspiring people to share
  • 17. The Mantra Design Test Test Implement Inspiring people to share
  • 18. More testing Sometimes you need to test interaction with external systems, like database access A test should be small, encapsulated, stand-alone So how do you test database access? Inspiring people to share
  • 19. Mocks & stubs Mock objects allow you to use fake objects instead of real implementations Stubs can be used to return hard-coded results Using them is actually (somewhat) easy with PHPUnit Inspiring people to share
  • 20. Saving in TYPO3CR Assumptions / Background • The Session object has a save() method • It uses a Storage_Backend implementation to do the work • That implementation has methods like addNode(), updateNode() and deleteNode() You need to make sure those are used when calling save() Inspiring people to share
  • 21. No FLOW3? No TDD!
  • 22. No TDD without FLOW3 Without Dependency Injection you cannot really do unit testing Inspiring people to share
  • 23. Dependencies Problem: Classes explicitly refer to other classes: Inspiring people to share
  • 24. Dependencies Try to test this class: Inspiring people to share
  • 25. Dependencies Unit Testing: You want to test a small unit You don't want to test • The Simple File Logger • The Card Repository Inspiring people to share
  • 26. Dependencies Unit Testing: You want to test a small unit You want to test • if the action returns a string representation of the random card it gets from the repository Inspiring people to share
  • 27. Dependency Injection A class doesn't ask for the instance of another class but gets it injected This methodology is referred to as the quot;Hollywood Principlequot;: quot;Don't call us, we'll call youquot; Enforces loose coupling and high cohesion Allows you to mock collaborators Makes you a better programmer Inspiring people to share
  • 29. Links & Literature Test-Driven Development By Example Kent Beck, Addison-Wesley Continuous Integration – Improving Software Quality and Reducing Risk Paul M. Duvall, Addison-Wesley xUnit Test Patterns – Refactoring Test Code Gerard Meszaros, Addison-Wesley Inspiring people to share
  • 30. Links & Literature FLOW3 http://flow3.typo3.org/ PHPUnit http://www.phpunit.de/ Hudson CI-Server https://hudson.dev.java.net/ TYPO3 Forge http://forge.typo3.org/ Inspiring people to share