SlideShare una empresa de Scribd logo
1 de 31
Descargar para leer sin conexión
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)

Más contenido relacionado

La actualidad más candente

La actualidad más candente (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
 

Destacado

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
 

Destacado (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 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
 

Similar 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
 

Más 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
 

Más 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

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
[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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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
 
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 2024Rafal Los
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
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...Miguel Araújo
 
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
 

Último (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
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...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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...
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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...
 
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
 

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