Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Test-driven development with PHPUnit
Search
Oliver Klee
August 05, 2022
Programming
0
370
Test-driven development with PHPUnit
Oliver Klee
August 05, 2022
Tweet
Share
More Decks by Oliver Klee
See All by Oliver Klee
Team-Management-Plattform
oliverklee
0
41
Vertrauen in Teams & Führung
oliverklee
0
190
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
20
Vertrauen in Teams & Führung
oliverklee
0
130
Testing von TYPO3-Extensions
oliverklee
0
41
Software-Qualität von Extensions automatisieren
oliverklee
1
31
Content-Synchronisierung
oliverklee
0
120
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
260
Motivationspsychologie und Gamification in Non-Profit-Organisationen
oliverklee
0
160
Other Decks in Programming
See All in Programming
関数型まつり2025登壇資料「関数プログラミングと再帰」
taisontsukada
2
840
GoのGenericsによるslice操作との付き合い方
syumai
2
670
Cursor Meetup Tokyo ゲノミクスとCursor: 進化と制約のあいだ
koido
2
1k
統一感のある Go コードを生成 AI の力で手にいれる
otakakot
0
3k
Cline指示通りに動かない? AI小説エージェントで学ぶ指示書の書き方と自動アップデートの仕組み
kamomeashizawa
1
550
関数型まつりレポート for JuliaTokai #22
antimon2
0
130
GoのWebAssembly活用パターン紹介
syumai
3
10k
Kotlin エンジニアへ送る:Swift 案件に参加させられる日に備えて~似てるけど色々違う Swift の仕様 / from Kotlin to Swift
lovee
1
240
Using AI Tools Around Software Development
inouehi
0
1.2k
業務自動化をJavaとSeleniumとAWS Lambdaで実現した方法
greenflagproject
1
120
A2A プロトコルを試してみる
azukiazusa1
2
720
エンジニア向け採用ピッチ資料
inusan
0
140
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.4k
Product Roadmaps are Hard
iamctodd
PRO
53
11k
Raft: Consensus for Rubyists
vanstee
140
7k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
For a Future-Friendly Web
brad_frost
179
9.8k
Typedesign – Prime Four
hannesfritz
42
2.7k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Practical Orchestrator
shlominoach
188
11k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.8k
Transcript
Test-driven development with PHPUnit Oliver Klee, 2022-08 @oliklee
| Mastodon:
[email protected]
|
[email protected]
About me Oliver „Oli“ Klee #bonn #extension-dev #workshop-teacher #unit-testing-guy #phpstan-guy
#typo3-ombudsperson #typo3-quality-assurance-initiative #gami fi cation-working-group #game-cooking #powermetal
???
The goals ✓ You have a clearer understanding on how
TDD works. ✓(optional) You get test-infected. ✓You learn at least 1 new testing pattern. ✓We all have fun.
The travel plan 1. getting starte d 2. concepts &
term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
The rules 1. There are no stupid questions. 2. The
joker rule.
The travel plan 1. getting starte d 2. concepts &
term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
Unit Tests?
Manual testing is cumbersome
Automated testing is fast
Unit tests for the TYPO3 Core
Unit Tests 406 (144) tests/s
Functional Tests 8.13 (1.97) tests/s
Acceptance Tests .009 (.003) tests/s
Verify that your code does what you expect
Make sure that your changes won‘t break anything
Keep others from breaking your code
Don’t break anything even in complex projects
Create a safety net for refactoring or for TYPO3
updates
Improve the structure of your code
Find the location of bugs
Green feels good!
Let’s get some terms straight
The two programming modes clean hacky
Testsuite Testcase Test Assertion Test Test Testcase
The life cycle of a test new FooTest(); setUp(); /**
@test */ lifeIsGood(); tearDown();
Code test-first write test write code refactor
The travel plan 1. getting starte d 2. concepts &
term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
The travel plan 1. getting starte d 2. concepts &
term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
https://github.com/TYPO3-Documentation/tea/ Branch: workshop/t3dd22 File: Exercises.md
The travel plan 1. getting starte d 2. concepts &
term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
Naming Tests
Use meaningful test names classCanBeInstantiated setTitleSetsTitle setSizeWithZeroThrowsException hasTitleForEmptyTitleReturnsFalse Name the
behavior. Name the preconditions. Name the method. Don’t use “works” or “works correctly”. measureFrubbleWorksCorrectly
The travel plan 1. getting starte d 2. concepts &
term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback