SlideShare a Scribd company logo
0Nicole Cordes, T3DD16 - Unit tests for dummies
Functional tests for dummies
» Introduction
» Basics
» Hands on
1Nicole Cordes, T3DD16 - Unit tests for dummies
Introduction
2Nicole Cordes, T3DD16 - Unit tests for dummies
INTRODUCTION
„Who is that girl?“
» Nicole Cordes
» working at CPS-IT GmbH in Berlin
» community activity since 2011
» Core and Security Team member
» contributing to multiple public extensions
» Slack: @IchHabRecht
» Twitter: @IchHabRecht
» Mail: typo3@cordes.co
3Nicole Cordes, T3DD16 - Unit tests for dummies
Basics
4Nicole Cordes, T3DD16 - Unit tests for dummies
BASICS
„Why do I need functional tests?“
» test a part of your software
» not about testing your functions or classes, but processes
» from a user's point of view
» for quality assurance (QA)
» unit tests don't ensure a correct workflow
» manual testing takes a lot of time
» encapsulated system (database) without site-effects or dependencies
5Nicole Cordes, T3DD16 - Unit tests for dummies
BASICS
„What are you talking about?“
test case
test
test
test
test
assertion
assertion
assertion
6Nicole Cordes, T3DD16 - Unit tests for dummies
BASICS
„What are you talking about?“
Processing of a test case
» find all tests within the class
» call one test after another
» test folder in typo3temp is created
» core is linked into test folder
» test extensions are linked into typo3conf/ext
» paths and files are linked
» LocalConfiguration.php is written
» PackageStates.php is written
» bootstrap is initialized
» database is created
» database scheme is imported
7Nicole Cordes, T3DD16 - Unit tests for dummies
BASICS
„What are you talking about?“
The life cycle of a test
» create an object of the test class
» call `setUp` method (protected!)
» objects and environment can be prepared
» call one test
» call `tearDown` method (protected!)
» objects and environment can be cleaned up
8Nicole Cordes, T3DD16 - Unit tests for dummies
Hands on
9Nicole Cordes, T3DD16 - Unit tests for dummies
USE CASE
„ext_testing aka blog_example“
10Nicole Cordes, T3DD16 - Unit tests for dummies
RUNNING TESTS
„How to run tests from CLI?“
» clone TYPO3 core
» run `composer install`
» use the cloned core for your development
» run `typo3_src/bin/phpunit -c typo3/sysext/core/Build/FunctionalTests.xml typo3conf/ext/ext_testing`
» ! be aware that the functional tests dirty your database
11Nicole Cordes, T3DD16 - Unit tests for dummies
RUNNING TESTS
„How to use an own MySQL instance?“
On Unix
» sudo mkdir /tmp/mysqld-testing
» sudo chmod 700 /tmp/mysqld-testing
» sudo chown mysql:mysql /tmp/mysqld-testing
» sudo mysqld_safe --port=3307 --socket="/var/run/mysqld/mysqld-testing.sock" --user mysql --pid-
file="/var/run/mysqld/mysqld-testing.pid" --datadir="/tmp/mysqld-testing" --skip-grant-tables run
» typo3DatabaseHost="localhost" typo3DatabasePort=3307 typo3DatabaseName=“ext-testing" 
typo3DatabaseUsername=“root" typo3DatabasePassword="" 
typo3_src/bin/phpunit -c typo3/sysext/core/Build/FunctionalTests.xml
12Nicole Cordes, T3DD16 - Unit tests for dummies
RUNNING TESTS
„How to use an own MySQL instance?“
On Windows (preparation)
» copy "C:Program FilesMySQL Servermy.ini“ to "C:Program FilesMySQL Servermy-testing.ini“
» change “port=3306” to “port=3307” in [client] and [mysqld] section
» change datadir=“C:/ProgramData/MySQL/MySQL Server 5.5/data” to
datadir=“C:/ProgramData/MySQL/MySQL Server 5.5/data-testing”
» change innodb_data_home_dir="C:/ProgramData/MySQL InnoDB Datafiles/“ to
innodb_data_home_dir="C:/ProgramData/MySQL InnoDB Datafiles Testing/"
» create folder “C:/ProgramData/MySQL/MySQL Server 5.5/data-testing”
» copy mysql folder, ib_logfile0 and ib_logfile1 from original data folder
» copy "C:/ProgramData/MySQL InnoDB Datafiles/“ to "C:/ProgramData/MySQL InnoDB Datafiles Testing/“
13Nicole Cordes, T3DD16 - Unit tests for dummies
RUNNING TESTS
„How to use an own MySQL instance?“
On Windows (server handling)
» start server with "C:Program FilesMySQL Serverbinmysqld.exe" --defaults-file="C:Program
FilesMySQL Servermy-testing.ini“
» the server starts in the foreground (no new prompt appears until the server exits later)
» stop the server with "C:Program FilesMySQL Serverbinmysqladmin.exe" -u root -p --port=3307
shutdown
» cmd /C “SET typo3DatabaseHost=localhost && SET typo3DatabasePort=3307 && 
SET typo3DatabaseName=ext-testing && SET typo3DatabaseUsername=root && 
SET typo3DatabasePassword= && 
typo3_srcbinphpunit -c typo3/sysext/core/Build/FunctionalTests.xml”
18Nicole Cordes, T3DD16 - Unit tests for dummies
CODING FUNCTIONAL TESTS
„How does functional testing work?“
I
» set up your expectations
» define static requirements
» add a test case for your class
» implement requirements and test (decouple objects as much as you can)
» implement assertion
19Nicole Cordes, T3DD16 - Unit tests for dummies
CODING FUNCTIONAL TESTS
„How does functional testing work?“
II
» move your extension to GitHub
» set up the travis service in your repository settings
» add a composer.json file
» add .travis.yml
20Nicole Cordes, T3DD16 - Unit tests for dummies
Thank you
for your attention!

More Related Content

PDF
Unit tests for dummies
PDF
Functional tests with TYPO3
PPTX
SymfonyCon Berlin 2016 Jenkins Deployment Pipelines
KEY
Fxug@北陸in富山 - Flex Unit4Beta1+α -
PDF
JS and patterns
PDF
The JavaFX Ecosystem
PDF
Making the Most of Your Gradle Build
PPTX
Java Libraries You Can’t Afford to Miss
Unit tests for dummies
Functional tests with TYPO3
SymfonyCon Berlin 2016 Jenkins Deployment Pipelines
Fxug@北陸in富山 - Flex Unit4Beta1+α -
JS and patterns
The JavaFX Ecosystem
Making the Most of Your Gradle Build
Java Libraries You Can’t Afford to Miss

What's hot (18)

PDF
ReactJS for Programmers
PDF
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
PDF
Java Bytecode for Discriminating Developers - JavaZone 2011
PDF
Making the Most of Your Gradle Build
PDF
Everything as a code
PDF
Testing with PostgreSQL
PDF
Advanced VCL: how to use restart
PDF
Test Driven Documentation with Spring Rest Docs JEEConf2017
PDF
TDD CrashCourse Part5: Testing Techniques
PDF
Springを用いた社内ライブラリ開発
PPTX
EclipseMAT
PDF
iOS Behavior-Driven Development
PPT
Unit testing with Spock Framework
PDF
Java Libraries You Can’t Afford to Miss
PDF
Corruptbkp
KEY
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
DOCX
201913046 wahyu septiansyah network programing
PPT
ReactJS for Programmers
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Java Bytecode for Discriminating Developers - JavaZone 2011
Making the Most of Your Gradle Build
Everything as a code
Testing with PostgreSQL
Advanced VCL: how to use restart
Test Driven Documentation with Spring Rest Docs JEEConf2017
TDD CrashCourse Part5: Testing Techniques
Springを用いた社内ライブラリ開発
EclipseMAT
iOS Behavior-Driven Development
Unit testing with Spock Framework
Java Libraries You Can’t Afford to Miss
Corruptbkp
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
201913046 wahyu septiansyah network programing
Ad

Similar to Functional tests for dummies (20)

PDF
Gallio Crafting A Toolchain
PDF
Practical Chaos Engineering
PDF
Effective Benchmarks
PDF
Developers Testing - Girl Code at bloomon
PPT
Performance Analysis of Idle Programs
PDF
Python and test
PPTX
Iac d.damyanov 4.pptx
PDF
CBDW2014 - MockBox, get ready to mock your socks off!
PDF
How to Test Asynchronous Code (v2)
PDF
How and what to unit test
PDF
TDD super mondays-june-2014
PDF
Into The Box 2018 | Assert control over your legacy applications
KEY
Testing Zen
 
PDF
Creating Realistic Unit Tests with Testcontainers
PDF
Mon application web en 20 minutes
PDF
My web application in 20 minutes with Telosys
PDF
Seven deadly sins of ElasticSearch Benchmarking
PDF
how-to-bypass-AM-PPL
PPTX
Techniques for Preserving Scientific Software Executions: Preserve the Mess o...
PPT
.NET Debugging Workshop
Gallio Crafting A Toolchain
Practical Chaos Engineering
Effective Benchmarks
Developers Testing - Girl Code at bloomon
Performance Analysis of Idle Programs
Python and test
Iac d.damyanov 4.pptx
CBDW2014 - MockBox, get ready to mock your socks off!
How to Test Asynchronous Code (v2)
How and what to unit test
TDD super mondays-june-2014
Into The Box 2018 | Assert control over your legacy applications
Testing Zen
 
Creating Realistic Unit Tests with Testcontainers
Mon application web en 20 minutes
My web application in 20 minutes with Telosys
Seven deadly sins of ElasticSearch Benchmarking
how-to-bypass-AM-PPL
Techniques for Preserving Scientific Software Executions: Preserve the Mess o...
.NET Debugging Workshop
Ad

Recently uploaded (20)

PPTX
Digital Literacy And Online Safety on internet
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PPTX
Introduction to Information and Communication Technology
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PPTX
Introuction about ICD -10 and ICD-11 PPT.pptx
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PPTX
innovation process that make everything different.pptx
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PDF
Introduction to the IoT system, how the IoT system works
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
DOCX
Unit-3 cyber security network security of internet system
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PPTX
Funds Management Learning Material for Beg
PDF
Testing WebRTC applications at scale.pdf
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PPT
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
PPTX
Power Point - Lesson 3_2.pptx grad school presentation
PDF
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
Digital Literacy And Online Safety on internet
RPKI Status Update, presented by Makito Lay at IDNOG 10
Cloud-Scale Log Monitoring _ Datadog.pdf
Introduction to Information and Communication Technology
An introduction to the IFRS (ISSB) Stndards.pdf
Introuction about ICD -10 and ICD-11 PPT.pptx
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
innovation process that make everything different.pptx
Slides PDF The World Game (s) Eco Economic Epochs.pdf
Introduction to the IoT system, how the IoT system works
Tenda Login Guide: Access Your Router in 5 Easy Steps
Unit-3 cyber security network security of internet system
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
Module 1 - Cyber Law and Ethics 101.pptx
Funds Management Learning Material for Beg
Testing WebRTC applications at scale.pdf
Job_Card_System_Styled_lorem_ipsum_.pptx
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
Power Point - Lesson 3_2.pptx grad school presentation
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰

Functional tests for dummies

  • 1. 0Nicole Cordes, T3DD16 - Unit tests for dummies Functional tests for dummies » Introduction » Basics » Hands on
  • 2. 1Nicole Cordes, T3DD16 - Unit tests for dummies Introduction
  • 3. 2Nicole Cordes, T3DD16 - Unit tests for dummies INTRODUCTION „Who is that girl?“ » Nicole Cordes » working at CPS-IT GmbH in Berlin » community activity since 2011 » Core and Security Team member » contributing to multiple public extensions » Slack: @IchHabRecht » Twitter: @IchHabRecht » Mail: typo3@cordes.co
  • 4. 3Nicole Cordes, T3DD16 - Unit tests for dummies Basics
  • 5. 4Nicole Cordes, T3DD16 - Unit tests for dummies BASICS „Why do I need functional tests?“ » test a part of your software » not about testing your functions or classes, but processes » from a user's point of view » for quality assurance (QA) » unit tests don't ensure a correct workflow » manual testing takes a lot of time » encapsulated system (database) without site-effects or dependencies
  • 6. 5Nicole Cordes, T3DD16 - Unit tests for dummies BASICS „What are you talking about?“ test case test test test test assertion assertion assertion
  • 7. 6Nicole Cordes, T3DD16 - Unit tests for dummies BASICS „What are you talking about?“ Processing of a test case » find all tests within the class » call one test after another » test folder in typo3temp is created » core is linked into test folder » test extensions are linked into typo3conf/ext » paths and files are linked » LocalConfiguration.php is written » PackageStates.php is written » bootstrap is initialized » database is created » database scheme is imported
  • 8. 7Nicole Cordes, T3DD16 - Unit tests for dummies BASICS „What are you talking about?“ The life cycle of a test » create an object of the test class » call `setUp` method (protected!) » objects and environment can be prepared » call one test » call `tearDown` method (protected!) » objects and environment can be cleaned up
  • 9. 8Nicole Cordes, T3DD16 - Unit tests for dummies Hands on
  • 10. 9Nicole Cordes, T3DD16 - Unit tests for dummies USE CASE „ext_testing aka blog_example“
  • 11. 10Nicole Cordes, T3DD16 - Unit tests for dummies RUNNING TESTS „How to run tests from CLI?“ » clone TYPO3 core » run `composer install` » use the cloned core for your development » run `typo3_src/bin/phpunit -c typo3/sysext/core/Build/FunctionalTests.xml typo3conf/ext/ext_testing` » ! be aware that the functional tests dirty your database
  • 12. 11Nicole Cordes, T3DD16 - Unit tests for dummies RUNNING TESTS „How to use an own MySQL instance?“ On Unix » sudo mkdir /tmp/mysqld-testing » sudo chmod 700 /tmp/mysqld-testing » sudo chown mysql:mysql /tmp/mysqld-testing » sudo mysqld_safe --port=3307 --socket="/var/run/mysqld/mysqld-testing.sock" --user mysql --pid- file="/var/run/mysqld/mysqld-testing.pid" --datadir="/tmp/mysqld-testing" --skip-grant-tables run » typo3DatabaseHost="localhost" typo3DatabasePort=3307 typo3DatabaseName=“ext-testing" typo3DatabaseUsername=“root" typo3DatabasePassword="" typo3_src/bin/phpunit -c typo3/sysext/core/Build/FunctionalTests.xml
  • 13. 12Nicole Cordes, T3DD16 - Unit tests for dummies RUNNING TESTS „How to use an own MySQL instance?“ On Windows (preparation) » copy "C:Program FilesMySQL Servermy.ini“ to "C:Program FilesMySQL Servermy-testing.ini“ » change “port=3306” to “port=3307” in [client] and [mysqld] section » change datadir=“C:/ProgramData/MySQL/MySQL Server 5.5/data” to datadir=“C:/ProgramData/MySQL/MySQL Server 5.5/data-testing” » change innodb_data_home_dir="C:/ProgramData/MySQL InnoDB Datafiles/“ to innodb_data_home_dir="C:/ProgramData/MySQL InnoDB Datafiles Testing/" » create folder “C:/ProgramData/MySQL/MySQL Server 5.5/data-testing” » copy mysql folder, ib_logfile0 and ib_logfile1 from original data folder » copy "C:/ProgramData/MySQL InnoDB Datafiles/“ to "C:/ProgramData/MySQL InnoDB Datafiles Testing/“
  • 14. 13Nicole Cordes, T3DD16 - Unit tests for dummies RUNNING TESTS „How to use an own MySQL instance?“ On Windows (server handling) » start server with "C:Program FilesMySQL Serverbinmysqld.exe" --defaults-file="C:Program FilesMySQL Servermy-testing.ini“ » the server starts in the foreground (no new prompt appears until the server exits later) » stop the server with "C:Program FilesMySQL Serverbinmysqladmin.exe" -u root -p --port=3307 shutdown » cmd /C “SET typo3DatabaseHost=localhost && SET typo3DatabasePort=3307 && SET typo3DatabaseName=ext-testing && SET typo3DatabaseUsername=root && SET typo3DatabasePassword= && typo3_srcbinphpunit -c typo3/sysext/core/Build/FunctionalTests.xml”
  • 15. 18Nicole Cordes, T3DD16 - Unit tests for dummies CODING FUNCTIONAL TESTS „How does functional testing work?“ I » set up your expectations » define static requirements » add a test case for your class » implement requirements and test (decouple objects as much as you can) » implement assertion
  • 16. 19Nicole Cordes, T3DD16 - Unit tests for dummies CODING FUNCTIONAL TESTS „How does functional testing work?“ II » move your extension to GitHub » set up the travis service in your repository settings » add a composer.json file » add .travis.yml
  • 17. 20Nicole Cordes, T3DD16 - Unit tests for dummies Thank you for your attention!