SlideShare a Scribd company logo
1 of 31
Download to read 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)

More Related Content

What's hot

What's hot (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
 

Viewers also liked

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
 

Viewers also liked (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
 

Similar to 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
 

Similar to 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
 

More from 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
 

More from 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
 

Recently uploaded

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

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