SlideShare a Scribd company logo
1 of 14
Download to read offline
Real Values.
Start testing your extension NOW
TYPO3camp Berlin 2019
O MORE EXCUSES
Real Values.
Well ...
I really would like to do this testing stuff.
But I have no clue where to start.
Most common excuse
Real Values.
About
▪ Senior TYPO3 Developer @ sitegeist
▪ TYPO3 CMS Certified Developer
▪ Working with TYPO3 since version 3.8
▪ TYPO3 developer since 2004
▪ TYPO3 core contributor since 11/2014
▪ Cartographer, Food Blogger and
Square Dancer
▪ Twitter: @buccaneer23
Jan Helke
Real Values.
What to test?
I refuse to answer that
Audiences often understand "What ONLY to test?"
The obvious answer must be "Everything"
Ask yourself "Does this piece of code something meaningful?"
Real Values.
What (probably) not to test?
Classes/Domain/Model
• Should do only trivial stuff (e.g. getTitle(), setTitle())
• Business logic should be moved to Services or Utilities (e.g. getValidityDate())
Classes/Domain/Repository
• You can rely on the core to test that database stuff
Classes/Controller
• Should only be in control
• Gather data
• Call business logic
• Assign data to view
Real Values.
Testing methods
Unit testing
• Single units (e.g. single functions)
• Closed scope - only own code
• No 3rd party requirements (e.g. Database, TYPO3 Core functions)
Integration testing (a.k.a. functional testing)
• Composed functionality (e.g. "validate form and save values to database")
• Useful for public APIs (e.g. REST services)
• 3rd party requirements
(User) acceptance testing
• Frontend functionality
Real Values.
All units on deck
./composer.json
"require-dev": {
"typo3/testing-framework": "^4.12"
},
"scripts": {
"test:php-unit": "./bin/phpunit --color -d memory_limit=-1 ↵
-c ./Build/Testing/UnitTests.xml",
}
Real Values.
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="true"
backupStaticAttributes="false"
bootstrap="../../vendor/typo3/testing-framework/Resources/Core/Build/
UnitTestsBootstrap.php"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false">
<testsuites>
<testsuite name="testing_example">
<directory>../../Extension/testing_example/Tests/Unit</directory>
</testsuite>
</testsuites>
<filter>
<!-- add folders explicitly as some TER extensions throw errors -->
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../Extension/testing_example/Classes/</directory>
</whitelist>
</filter>
</phpunit>
Real Values.
And the functions as well
./composer.json
"require-dev": {
"typo3/testing-framework": "^4.12"
},
"scripts": {
"test:php-function": "rm -rf typo3temp/var/tests/functional-*; ↵
typo3DatabaseName="typo3_functional" typo3DatabaseHost="db" ↵
typo3DatabaseUsername="root" typo3DatabasePassword="root" ↵
./bin/phpunit -d memory_limit=-1 --colors ↵
-c ./Build/Testing/FunctionalTests.xml" ↵
}
Real Values.
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="true"
backupStaticAttributes="false"
bootstrap="../../vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false">
<testsuites>
<testsuite name="testing_example">
<directory>../../Extension/testing_example/Tests/Functional</directory>
</testsuite>
</testsuites>
<filter>
<!-- add folders explicitly as some TER extensions throw errors -->
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../Extension/testing_example/Classes/</directory>
</whitelist>
</filter>
</phpunit>
Real Values.
Bonus: Static code analysis
./composer.json
"require-dev": {
"phpstan/phpstan": "^0.10.6",
"saschaegerer/phpstan-typo3": "^0.10.0"
},
"scripts": {
"test:php-static": "./bin/phpstan --configuration=./Build/Testing/ ↵
phpstan.neon analyse --no-progress Extension/ --level=5",
}
./Build/Testing/phpstan.neon
includes:
- ../../vendor/saschaegerer/phpstan-typo3/extension.neon
parameters:
bootstrap: %rootDir%/../../saschaegerer/phpstan-typo3/src/ ↵
PhpstanTypo3Bootstrap.php
Real Values.
Finally: pretty pretty code
Use the opportunity - run some code style checking all the time
./composer.json
"scripts": {
"lint:editorconfig": "./bin/editorconfig-checker ./Extension/*",
"lint:php": "./bin/php-cs-fixer fix --dry-run --diff ↵
--config ./Build/Testing/.php_cs.php",
"test" : [
"@lint:editorconfig",
"@lint:php",
"@test:php-static",
"@test:php-unit",
"@test:php-function"
],
}
Real Values.
Thank you. Questions?
Real Values.
Sources
• https://github.com/sitegeist/typo3-testing-example
• https://www.slideshare.net/JanHelke
• https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/Testing/Index.html

More Related Content

What's hot

Five Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal SiteFive Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal SiteMediacurrent
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in YiiIlPeach
 
Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Sam Becker
 
EclipseMAT
EclipseMATEclipseMAT
EclipseMATAli Bahu
 
CakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldCakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldGraham Weldon
 
3 introduction-php-mvc-cakephp-m3-getting-started-slides
3 introduction-php-mvc-cakephp-m3-getting-started-slides3 introduction-php-mvc-cakephp-m3-getting-started-slides
3 introduction-php-mvc-cakephp-m3-getting-started-slidesMasterCode.vn
 
Drupalcamp Simpletest
Drupalcamp SimpletestDrupalcamp Simpletest
Drupalcamp Simpletestlyricnz
 
Automation testing with Drupal 8
Automation testing with Drupal 8Automation testing with Drupal 8
Automation testing with Drupal 8nagpalprachi
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial之宇 趙
 
Codeception presentation
Codeception presentationCodeception presentation
Codeception presentationAndrei Burian
 
4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slidesMasterCode.vn
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for BeginnersJason Davies
 
How to test models using php unit testing framework?
How to test models using php unit testing framework?How to test models using php unit testing framework?
How to test models using php unit testing framework?satejsahu
 
Continuous Integration Testing in Django
Continuous Integration Testing in DjangoContinuous Integration Testing in Django
Continuous Integration Testing in DjangoKevin Harvey
 
Auditing Drupal Sites
Auditing Drupal SitesAuditing Drupal Sites
Auditing Drupal SitesExove
 
Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentEnhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentYao Nien Chung
 
Scryent: Plone - Hone Your Test Fu
Scryent: Plone - Hone Your Test FuScryent: Plone - Hone Your Test Fu
Scryent: Plone - Hone Your Test FuJordan Baker
 

What's hot (19)

Five Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal SiteFive Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal Site
 
Codeception
CodeceptionCodeception
Codeception
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in Yii
 
Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8
 
Django by rj
Django by rjDjango by rj
Django by rj
 
EclipseMAT
EclipseMATEclipseMAT
EclipseMAT
 
CakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldCakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your world
 
3 introduction-php-mvc-cakephp-m3-getting-started-slides
3 introduction-php-mvc-cakephp-m3-getting-started-slides3 introduction-php-mvc-cakephp-m3-getting-started-slides
3 introduction-php-mvc-cakephp-m3-getting-started-slides
 
Drupalcamp Simpletest
Drupalcamp SimpletestDrupalcamp Simpletest
Drupalcamp Simpletest
 
Automation testing with Drupal 8
Automation testing with Drupal 8Automation testing with Drupal 8
Automation testing with Drupal 8
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial
 
Codeception presentation
Codeception presentationCodeception presentation
Codeception presentation
 
4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for Beginners
 
How to test models using php unit testing framework?
How to test models using php unit testing framework?How to test models using php unit testing framework?
How to test models using php unit testing framework?
 
Continuous Integration Testing in Django
Continuous Integration Testing in DjangoContinuous Integration Testing in Django
Continuous Integration Testing in Django
 
Auditing Drupal Sites
Auditing Drupal SitesAuditing Drupal Sites
Auditing Drupal Sites
 
Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentEnhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order component
 
Scryent: Plone - Hone Your Test Fu
Scryent: Plone - Hone Your Test FuScryent: Plone - Hone Your Test Fu
Scryent: Plone - Hone Your Test Fu
 

Similar to Start testing your extension NOW

Testing the frontend
Testing the frontendTesting the frontend
Testing the frontendHeiko Hardt
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFXHendrik Ebbers
 
Grails patterns and practices
Grails patterns and practicesGrails patterns and practices
Grails patterns and practicespaulbowler
 
Code igniter unittest-part1
Code igniter unittest-part1Code igniter unittest-part1
Code igniter unittest-part1Albert Rosa
 
REST API testing with SpecFlow
REST API testing with SpecFlowREST API testing with SpecFlow
REST API testing with SpecFlowAiste Stikliute
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingSteven Smith
 
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014FalafelSoftware
 
Categories of automation testing
Categories of automation testingCategories of automation testing
Categories of automation testingArati Joshi
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiRan Mizrahi
 
Introduction to testing in Rails
Introduction to testing in RailsIntroduction to testing in Rails
Introduction to testing in Railsbenlcollins
 
Mountebank and you
Mountebank and youMountebank and you
Mountebank and youVodqaBLR
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017Ortus Solutions, Corp
 
Testing - How Vital and How Easy to use
Testing - How Vital and How Easy to useTesting - How Vital and How Easy to use
Testing - How Vital and How Easy to useUma Ghotikar
 
Qtp Training
Qtp TrainingQtp Training
Qtp Trainingmehramit
 
API and DB design with Boolean
API and DB design with BooleanAPI and DB design with Boolean
API and DB design with BooleanMohanraj Nagasamy
 
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)Jen Wong
 
Advanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.com
Advanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.comAdvanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.com
Advanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.comDevOpsDays Tel Aviv
 

Similar to Start testing your extension NOW (20)

Testing the frontend
Testing the frontendTesting the frontend
Testing the frontend
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 
Grails patterns and practices
Grails patterns and practicesGrails patterns and practices
Grails patterns and practices
 
Code igniter unittest-part1
Code igniter unittest-part1Code igniter unittest-part1
Code igniter unittest-part1
 
REST API testing with SpecFlow
REST API testing with SpecFlowREST API testing with SpecFlow
REST API testing with SpecFlow
 
Defensive Apex Programming
Defensive Apex ProgrammingDefensive Apex Programming
Defensive Apex Programming
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit Testing
 
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
 
Reusable Apps
Reusable AppsReusable Apps
Reusable Apps
 
Categories of automation testing
Categories of automation testingCategories of automation testing
Categories of automation testing
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
 
Introduction to testing in Rails
Introduction to testing in RailsIntroduction to testing in Rails
Introduction to testing in Rails
 
Modern Python Testing
Modern Python TestingModern Python Testing
Modern Python Testing
 
Mountebank and you
Mountebank and youMountebank and you
Mountebank and you
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
 
Testing - How Vital and How Easy to use
Testing - How Vital and How Easy to useTesting - How Vital and How Easy to use
Testing - How Vital and How Easy to use
 
Qtp Training
Qtp TrainingQtp Training
Qtp Training
 
API and DB design with Boolean
API and DB design with BooleanAPI and DB design with Boolean
API and DB design with Boolean
 
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
 
Advanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.com
Advanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.comAdvanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.com
Advanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.com
 

Recently uploaded

Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...FIDO Alliance
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...FIDO Alliance
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCzechDreamin
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessUXDXConf
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsStefano
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfChristopherTHyatt
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...CzechDreamin
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoTAnalytics
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 

Recently uploaded (20)

Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 

Start testing your extension NOW

  • 1. Real Values. Start testing your extension NOW TYPO3camp Berlin 2019 O MORE EXCUSES
  • 2. Real Values. Well ... I really would like to do this testing stuff. But I have no clue where to start. Most common excuse
  • 3. Real Values. About ▪ Senior TYPO3 Developer @ sitegeist ▪ TYPO3 CMS Certified Developer ▪ Working with TYPO3 since version 3.8 ▪ TYPO3 developer since 2004 ▪ TYPO3 core contributor since 11/2014 ▪ Cartographer, Food Blogger and Square Dancer ▪ Twitter: @buccaneer23 Jan Helke
  • 4. Real Values. What to test? I refuse to answer that Audiences often understand "What ONLY to test?" The obvious answer must be "Everything" Ask yourself "Does this piece of code something meaningful?"
  • 5. Real Values. What (probably) not to test? Classes/Domain/Model • Should do only trivial stuff (e.g. getTitle(), setTitle()) • Business logic should be moved to Services or Utilities (e.g. getValidityDate()) Classes/Domain/Repository • You can rely on the core to test that database stuff Classes/Controller • Should only be in control • Gather data • Call business logic • Assign data to view
  • 6. Real Values. Testing methods Unit testing • Single units (e.g. single functions) • Closed scope - only own code • No 3rd party requirements (e.g. Database, TYPO3 Core functions) Integration testing (a.k.a. functional testing) • Composed functionality (e.g. "validate form and save values to database") • Useful for public APIs (e.g. REST services) • 3rd party requirements (User) acceptance testing • Frontend functionality
  • 7. Real Values. All units on deck ./composer.json "require-dev": { "typo3/testing-framework": "^4.12" }, "scripts": { "test:php-unit": "./bin/phpunit --color -d memory_limit=-1 ↵ -c ./Build/Testing/UnitTests.xml", }
  • 8. Real Values. <?xml version="1.0" encoding="UTF-8"?> <phpunit backupGlobals="true" backupStaticAttributes="false" bootstrap="../../vendor/typo3/testing-framework/Resources/Core/Build/ UnitTestsBootstrap.php" convertErrorsToExceptions="true" convertWarningsToExceptions="true" forceCoversAnnotation="false" processIsolation="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" verbose="false"> <testsuites> <testsuite name="testing_example"> <directory>../../Extension/testing_example/Tests/Unit</directory> </testsuite> </testsuites> <filter> <!-- add folders explicitly as some TER extensions throw errors --> <whitelist processUncoveredFilesFromWhitelist="true"> <directory suffix=".php">../Extension/testing_example/Classes/</directory> </whitelist> </filter> </phpunit>
  • 9. Real Values. And the functions as well ./composer.json "require-dev": { "typo3/testing-framework": "^4.12" }, "scripts": { "test:php-function": "rm -rf typo3temp/var/tests/functional-*; ↵ typo3DatabaseName="typo3_functional" typo3DatabaseHost="db" ↵ typo3DatabaseUsername="root" typo3DatabasePassword="root" ↵ ./bin/phpunit -d memory_limit=-1 --colors ↵ -c ./Build/Testing/FunctionalTests.xml" ↵ }
  • 10. Real Values. <?xml version="1.0" encoding="UTF-8"?> <phpunit backupGlobals="true" backupStaticAttributes="false" bootstrap="../../vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php" convertErrorsToExceptions="true" convertWarningsToExceptions="true" forceCoversAnnotation="false" processIsolation="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" verbose="false"> <testsuites> <testsuite name="testing_example"> <directory>../../Extension/testing_example/Tests/Functional</directory> </testsuite> </testsuites> <filter> <!-- add folders explicitly as some TER extensions throw errors --> <whitelist processUncoveredFilesFromWhitelist="true"> <directory suffix=".php">../Extension/testing_example/Classes/</directory> </whitelist> </filter> </phpunit>
  • 11. Real Values. Bonus: Static code analysis ./composer.json "require-dev": { "phpstan/phpstan": "^0.10.6", "saschaegerer/phpstan-typo3": "^0.10.0" }, "scripts": { "test:php-static": "./bin/phpstan --configuration=./Build/Testing/ ↵ phpstan.neon analyse --no-progress Extension/ --level=5", } ./Build/Testing/phpstan.neon includes: - ../../vendor/saschaegerer/phpstan-typo3/extension.neon parameters: bootstrap: %rootDir%/../../saschaegerer/phpstan-typo3/src/ ↵ PhpstanTypo3Bootstrap.php
  • 12. Real Values. Finally: pretty pretty code Use the opportunity - run some code style checking all the time ./composer.json "scripts": { "lint:editorconfig": "./bin/editorconfig-checker ./Extension/*", "lint:php": "./bin/php-cs-fixer fix --dry-run --diff ↵ --config ./Build/Testing/.php_cs.php", "test" : [ "@lint:editorconfig", "@lint:php", "@test:php-static", "@test:php-unit", "@test:php-function" ], }
  • 14. Real Values. Sources • https://github.com/sitegeist/typo3-testing-example • https://www.slideshare.net/JanHelke • https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/Testing/Index.html