SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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
 

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

Similaire à 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 - 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
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingSteven Smith
 
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
 

Similaire à 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 - 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
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit Testing
 
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
 

Dernier

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
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
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Dernier (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
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
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
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...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

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