SlideShare a Scribd company logo
1 of 21
Download to read offline
0Nicole Cordes, T3DD16 - Unit tests for dummies
Unit 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 unit tests?“
» verify your code does what you expect
» manual testing is slow and cumbersome
» automate testing is fast and cool
» new changes don’t break existing functionality
» keep others from breaking your code
» safety net for refactorings
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 dataProvider and store return values
» call one test after another
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/UnitTests.xml typo3conf/ext/ext_testing`
11Nicole Cordes, T3DD16 - Unit tests for dummies
RUNNING TESTS
„How to run tests within PhpStorm?“
» set up PHP version for your project
12Nicole Cordes, T3DD16 - Unit tests for dummies
RUNNING TESTS
„How to run tests within PhpStorm?“
» set up configuration
13Nicole Cordes, T3DD16 - Unit tests for dummies
RUNNING TESTS
„How to run tests within PhpStorm?“
» add environment variable
14Nicole Cordes, T3DD16 - Unit tests for dummies
RUNNING TESTS
„How to run tests within PhpStorm?“
» run test class or single test
15Nicole Cordes, T3DD16 - Unit tests for dummies
GENERATED TESTS
„Why should generated tests be deleted?“
ControllerTest
» due to Extbase all generated actions are very small
» aggregate information and passing it to the view
» test if data is visible (= assigned correctly) is not part of unit testing
» acceptance testing
» all those tests should be rewritten as functional tests (see you on Sunday )
16Nicole Cordes, T3DD16 - Unit tests for dummies
GENERATED TESTS
„Why should generated tests be deleted?“
ModelTest
» generated tests simply test getter and setter
» no need to test getter and/or setter as long as they don’t implement functionality
17Nicole Cordes, T3DD16 - Unit tests for dummies
CODING REAL UNIT TESTS
„How does real unit testing work?“
I
» no own logic means no need for unit tests
» we don’t need to test the core
» tests for Extbase are done within the core
» no need for unit tests doesn’t mean no need for other kinds of testing!
18Nicole Cordes, T3DD16 - Unit tests for dummies
CODING REAL UNIT TESTS
„How does real unit testing work?“
II
» add own logic
» add test case for your class
» add white- and blacklist tests
» switch to dataProvider and think about edge cases
19Nicole Cordes, T3DD16 - Unit tests for dummies
CODING REAL UNIT TESTS
„How does real unit testing work?“
III
» add more advanced logic
» add test case for your class
» remove coupling to external dependencies (mocking)
» define test expectations
» switch mocks to prophecies to be more verbose on decoupling
20Nicole Cordes, T3DD16 - Unit tests for dummies
Thank you
for your attention!

More Related Content

What's hot

Tests unitaires mock_kesako_20130516
Tests unitaires mock_kesako_20130516Tests unitaires mock_kesako_20130516
Tests unitaires mock_kesako_20130516SOAT
 
DevOps Fest 2020. Philipp Krenn. Scale Your Auditing Events
DevOps Fest 2020. Philipp Krenn. Scale Your Auditing EventsDevOps Fest 2020. Philipp Krenn. Scale Your Auditing Events
DevOps Fest 2020. Philipp Krenn. Scale Your Auditing EventsDevOps_Fest
 
ReactJS for Programmers
ReactJS for ProgrammersReactJS for Programmers
ReactJS for ProgrammersDavid Rodenas
 
TDD CrashCourse Part5: Testing Techniques
TDD CrashCourse Part5: Testing TechniquesTDD CrashCourse Part5: Testing Techniques
TDD CrashCourse Part5: Testing TechniquesDavid Rodenas
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to MissJava Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to MissAndres Almiray
 
Smarter Testing With Spock
Smarter Testing With SpockSmarter Testing With Spock
Smarter Testing With SpockIT Weekend
 
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan JurkovicInfinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan JurkovicInfinum
 
Implicit and Explicit waits in Selenium WebDriwer, how to.
Implicit and Explicit waits in Selenium WebDriwer, how to.Implicit and Explicit waits in Selenium WebDriwer, how to.
Implicit and Explicit waits in Selenium WebDriwer, how to.Yaroslav Pernerovsky
 
Automated Abstraction of Flow of Control in a System of Distributed Software...
Automated Abstraction of Flow of Control in a System of Distributed  Software...Automated Abstraction of Flow of Control in a System of Distributed  Software...
Automated Abstraction of Flow of Control in a System of Distributed Software...nimak
 
EclipseMAT
EclipseMATEclipseMAT
EclipseMATAli Bahu
 
Unit/Integration Testing using Spock
Unit/Integration Testing using SpockUnit/Integration Testing using Spock
Unit/Integration Testing using SpockAnuj Aneja
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGuillaume Laforge
 
iOS Unit test getting stared
iOS Unit test getting starediOS Unit test getting stared
iOS Unit test getting staredLiyao Chen
 

What's hot (20)

Spock Framework
Spock FrameworkSpock Framework
Spock Framework
 
Tests unitaires mock_kesako_20130516
Tests unitaires mock_kesako_20130516Tests unitaires mock_kesako_20130516
Tests unitaires mock_kesako_20130516
 
The JavaFX Ecosystem
The JavaFX EcosystemThe JavaFX Ecosystem
The JavaFX Ecosystem
 
DevOps Fest 2020. Philipp Krenn. Scale Your Auditing Events
DevOps Fest 2020. Philipp Krenn. Scale Your Auditing EventsDevOps Fest 2020. Philipp Krenn. Scale Your Auditing Events
DevOps Fest 2020. Philipp Krenn. Scale Your Auditing Events
 
Thread dumps
Thread dumpsThread dumps
Thread dumps
 
ReactJS for Programmers
ReactJS for ProgrammersReactJS for Programmers
ReactJS for Programmers
 
TDD CrashCourse Part5: Testing Techniques
TDD CrashCourse Part5: Testing TechniquesTDD CrashCourse Part5: Testing Techniques
TDD CrashCourse Part5: Testing Techniques
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to MissJava Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
 
Smarter Testing With Spock
Smarter Testing With SpockSmarter Testing With Spock
Smarter Testing With Spock
 
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan JurkovicInfinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
 
WebDriver Waits
WebDriver WaitsWebDriver Waits
WebDriver Waits
 
Implicit and Explicit waits in Selenium WebDriwer, how to.
Implicit and Explicit waits in Selenium WebDriwer, how to.Implicit and Explicit waits in Selenium WebDriwer, how to.
Implicit and Explicit waits in Selenium WebDriwer, how to.
 
Automated Abstraction of Flow of Control in a System of Distributed Software...
Automated Abstraction of Flow of Control in a System of Distributed  Software...Automated Abstraction of Flow of Control in a System of Distributed  Software...
Automated Abstraction of Flow of Control in a System of Distributed Software...
 
Automation puzzlers
Automation puzzlersAutomation puzzlers
Automation puzzlers
 
Spock
SpockSpock
Spock
 
EclipseMAT
EclipseMATEclipseMAT
EclipseMAT
 
Unit/Integration Testing using Spock
Unit/Integration Testing using SpockUnit/Integration Testing using Spock
Unit/Integration Testing using Spock
 
groovy & grails - lecture 11
groovy & grails - lecture 11groovy & grails - lecture 11
groovy & grails - lecture 11
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
 
iOS Unit test getting stared
iOS Unit test getting starediOS Unit test getting stared
iOS Unit test getting stared
 

Viewers also liked

Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practicesnickokiss
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated TestingLee Englestone
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration TestingDavid Berliner
 
Unit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesUnit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesDerek Smith
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPTsuhasreddy1
 
Fluid Security
Fluid SecurityFluid Security
Fluid Securitycpsitgmbh
 
TYPO3 Caching
TYPO3 CachingTYPO3 Caching
TYPO3 Cachingcpsitgmbh
 
Using evolutionary testing to improve efficiency and quality
Using evolutionary testing to improve efficiency and qualityUsing evolutionary testing to improve efficiency and quality
Using evolutionary testing to improve efficiency and qualityFaysal Ahmed
 
TYPO3 Contribution Bootup Day
TYPO3 Contribution Bootup DayTYPO3 Contribution Bootup Day
TYPO3 Contribution Bootup Daycpsitgmbh
 
Managing Projects With HomeSpot
Managing Projects With HomeSpotManaging Projects With HomeSpot
Managing Projects With HomeSpotDerek Smith
 
Robot Chickens! How a Netduino runs our backyard chicken coop
Robot Chickens!  How a Netduino runs our backyard chicken coopRobot Chickens!  How a Netduino runs our backyard chicken coop
Robot Chickens! How a Netduino runs our backyard chicken coopDerek Smith
 
Building data driven mobile apps with phone gap and webapi
Building data driven mobile apps with phone gap and webapiBuilding data driven mobile apps with phone gap and webapi
Building data driven mobile apps with phone gap and webapiDerek Smith
 
What's New in ASP.NET Identity - TRINUG Sept 2014
What's New in ASP.NET Identity - TRINUG Sept 2014What's New in ASP.NET Identity - TRINUG Sept 2014
What's New in ASP.NET Identity - TRINUG Sept 2014Derek Smith
 
Zawód tester. Wprowadzenie.
Zawód tester. Wprowadzenie.Zawód tester. Wprowadzenie.
Zawód tester. Wprowadzenie.Radoslaw Smilgin
 
Unit Testing And Mocking
Unit Testing And MockingUnit Testing And Mocking
Unit Testing And MockingJoe Wilson
 

Viewers also liked (20)

Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
 
Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practices
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated Testing
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration Testing
 
Unit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesUnit Testing Concepts and Best Practices
Unit Testing Concepts and Best Practices
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPT
 
Fluid Security
Fluid SecurityFluid Security
Fluid Security
 
Hooks
HooksHooks
Hooks
 
TYPO3 Caching
TYPO3 CachingTYPO3 Caching
TYPO3 Caching
 
Using evolutionary testing to improve efficiency and quality
Using evolutionary testing to improve efficiency and qualityUsing evolutionary testing to improve efficiency and quality
Using evolutionary testing to improve efficiency and quality
 
TYPO3 Contribution Bootup Day
TYPO3 Contribution Bootup DayTYPO3 Contribution Bootup Day
TYPO3 Contribution Bootup Day
 
Managing Projects With HomeSpot
Managing Projects With HomeSpotManaging Projects With HomeSpot
Managing Projects With HomeSpot
 
Robot Chickens! How a Netduino runs our backyard chicken coop
Robot Chickens!  How a Netduino runs our backyard chicken coopRobot Chickens!  How a Netduino runs our backyard chicken coop
Robot Chickens! How a Netduino runs our backyard chicken coop
 
Building data driven mobile apps with phone gap and webapi
Building data driven mobile apps with phone gap and webapiBuilding data driven mobile apps with phone gap and webapi
Building data driven mobile apps with phone gap and webapi
 
Unit testing
Unit testingUnit testing
Unit testing
 
What's New in ASP.NET Identity - TRINUG Sept 2014
What's New in ASP.NET Identity - TRINUG Sept 2014What's New in ASP.NET Identity - TRINUG Sept 2014
What's New in ASP.NET Identity - TRINUG Sept 2014
 
Junit
JunitJunit
Junit
 
JUNit Presentation
JUNit PresentationJUNit Presentation
JUNit Presentation
 
Zawód tester. Wprowadzenie.
Zawód tester. Wprowadzenie.Zawód tester. Wprowadzenie.
Zawód tester. Wprowadzenie.
 
Unit Testing And Mocking
Unit Testing And MockingUnit Testing And Mocking
Unit Testing And Mocking
 

Similar to Unit tests for dummies

How and what to unit test
How and what to unit testHow and what to unit test
How and what to unit testEugenio Lentini
 
Testing, Learning and Professionalism — 20171214
Testing, Learning and Professionalism — 20171214Testing, Learning and Professionalism — 20171214
Testing, Learning and Professionalism — 20171214David Rodenas
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)Felix Geisendörfer
 
Creating Realistic Unit Tests with Testcontainers
Creating Realistic Unit Tests with TestcontainersCreating Realistic Unit Tests with Testcontainers
Creating Realistic Unit Tests with TestcontainersPaul Balogh
 
Test-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxTest-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxVictor Rentea
 
SPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic librarySPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic libraryAdaCore
 
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red TeamWhat is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red TeamMITRE ATT&CK
 
Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Danny Preussler
 
Python testing like a pro by Keith Yang
Python testing like a pro by Keith YangPython testing like a pro by Keith Yang
Python testing like a pro by Keith YangPYCON MY PLT
 
Machine Learning Infrastructure
Machine Learning InfrastructureMachine Learning Infrastructure
Machine Learning InfrastructureSigOpt
 
Mocking vtcc3 - en
Mocking   vtcc3 - enMocking   vtcc3 - en
Mocking vtcc3 - envgrondin
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindAndreas Czakaj
 
Behaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About TestingBehaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About Testingdn
 
Bdd and-testing
Bdd and-testingBdd and-testing
Bdd and-testingmalcolmt
 

Similar to Unit tests for dummies (20)

How and what to unit test
How and what to unit testHow and what to unit test
How and what to unit test
 
Testing, Learning and Professionalism — 20171214
Testing, Learning and Professionalism — 20171214Testing, Learning and Professionalism — 20171214
Testing, Learning and Professionalism — 20171214
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)
 
TDD a piccoli passi
TDD a piccoli passiTDD a piccoli passi
TDD a piccoli passi
 
Creating Realistic Unit Tests with Testcontainers
Creating Realistic Unit Tests with TestcontainersCreating Realistic Unit Tests with Testcontainers
Creating Realistic Unit Tests with Testcontainers
 
Test-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxTest-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptx
 
Effective Benchmarks
Effective BenchmarksEffective Benchmarks
Effective Benchmarks
 
SPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic librarySPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic library
 
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red TeamWhat is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
 
Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)
 
Gallio Crafting A Toolchain
Gallio Crafting A ToolchainGallio Crafting A Toolchain
Gallio Crafting A Toolchain
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Python and test
Python and testPython and test
Python and test
 
Python testing like a pro by Keith Yang
Python testing like a pro by Keith YangPython testing like a pro by Keith Yang
Python testing like a pro by Keith Yang
 
Machine Learning Infrastructure
Machine Learning InfrastructureMachine Learning Infrastructure
Machine Learning Infrastructure
 
5. DFT.pptx
5. DFT.pptx5. DFT.pptx
5. DFT.pptx
 
Mocking vtcc3 - en
Mocking   vtcc3 - enMocking   vtcc3 - en
Mocking vtcc3 - en
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mind
 
Behaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About TestingBehaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About Testing
 
Bdd and-testing
Bdd and-testingBdd and-testing
Bdd and-testing
 

Recently uploaded

Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
Intellectual property rightsand its types.pptx
Intellectual property rightsand its types.pptxIntellectual property rightsand its types.pptx
Intellectual property rightsand its types.pptxBipin Adhikari
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一Fs
 
Elevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New OrleansElevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New Orleanscorenetworkseo
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxeditsforyah
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一Fs
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Dana Luther
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 

Recently uploaded (20)

Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
Intellectual property rightsand its types.pptx
Intellectual property rightsand its types.pptxIntellectual property rightsand its types.pptx
Intellectual property rightsand its types.pptx
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
 
Elevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New OrleansElevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New Orleans
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 

Unit tests for dummies

  • 1. 0Nicole Cordes, T3DD16 - Unit tests for dummies Unit 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 unit tests?“ » verify your code does what you expect » manual testing is slow and cumbersome » automate testing is fast and cool » new changes don’t break existing functionality » keep others from breaking your code » safety net for refactorings
  • 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 dataProvider and store return values » call one test after another
  • 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/UnitTests.xml typo3conf/ext/ext_testing`
  • 12. 11Nicole Cordes, T3DD16 - Unit tests for dummies RUNNING TESTS „How to run tests within PhpStorm?“ » set up PHP version for your project
  • 13. 12Nicole Cordes, T3DD16 - Unit tests for dummies RUNNING TESTS „How to run tests within PhpStorm?“ » set up configuration
  • 14. 13Nicole Cordes, T3DD16 - Unit tests for dummies RUNNING TESTS „How to run tests within PhpStorm?“ » add environment variable
  • 15. 14Nicole Cordes, T3DD16 - Unit tests for dummies RUNNING TESTS „How to run tests within PhpStorm?“ » run test class or single test
  • 16. 15Nicole Cordes, T3DD16 - Unit tests for dummies GENERATED TESTS „Why should generated tests be deleted?“ ControllerTest » due to Extbase all generated actions are very small » aggregate information and passing it to the view » test if data is visible (= assigned correctly) is not part of unit testing » acceptance testing » all those tests should be rewritten as functional tests (see you on Sunday )
  • 17. 16Nicole Cordes, T3DD16 - Unit tests for dummies GENERATED TESTS „Why should generated tests be deleted?“ ModelTest » generated tests simply test getter and setter » no need to test getter and/or setter as long as they don’t implement functionality
  • 18. 17Nicole Cordes, T3DD16 - Unit tests for dummies CODING REAL UNIT TESTS „How does real unit testing work?“ I » no own logic means no need for unit tests » we don’t need to test the core » tests for Extbase are done within the core » no need for unit tests doesn’t mean no need for other kinds of testing!
  • 19. 18Nicole Cordes, T3DD16 - Unit tests for dummies CODING REAL UNIT TESTS „How does real unit testing work?“ II » add own logic » add test case for your class » add white- and blacklist tests » switch to dataProvider and think about edge cases
  • 20. 19Nicole Cordes, T3DD16 - Unit tests for dummies CODING REAL UNIT TESTS „How does real unit testing work?“ III » add more advanced logic » add test case for your class » remove coupling to external dependencies (mocking) » define test expectations » switch mocks to prophecies to be more verbose on decoupling
  • 21. 20Nicole Cordes, T3DD16 - Unit tests for dummies Thank you for your attention!