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
410
0
Share
Test-driven development with PHPUnit
Oliver Klee
August 05, 2022
More Decks by Oliver Klee
See All by Oliver Klee
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
110
Team-Management-Plattform
oliverklee
0
77
Vertrauen in Teams & Führung
oliverklee
0
310
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
52
Vertrauen in Teams & Führung
oliverklee
0
170
Testing von TYPO3-Extensions
oliverklee
0
95
Software-Qualität von Extensions automatisieren
oliverklee
1
61
Content-Synchronisierung
oliverklee
0
180
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
370
Other Decks in Programming
See All in Programming
From Formal Specification to Property Based Test
ohbarye
0
720
Kingdom of the Machine
yui_knk
2
1.4k
Road to RubyKaigi: Play Hard(ware)
makicamel
1
550
PHPer、Cloudflare に引っ越す
suguruooki
1
140
t *testing.T は どこからやってくるの?
otakakot
1
910
20260514 - build with ai 2026 - build LINE Bot with Gemini CLI
line_developers_tw
PRO
0
280
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
760
Structured Concurrency, Scoped Values and Joiners in the JDK 25 26 27
josepaumard
1
140
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
5
1.5k
「OSSがあるなら自作するな」は AI時代も正しいか ── Build vs Adopt の新しい判断基準
kumorn5s
6
1.8k
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
360
Making the RBS Parser Faster
soutaro
0
660
Featured
See All Featured
Game over? The fight for quality and originality in the time of robots
wayneb77
1
170
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Testing 201, or: Great Expectations
jmmastey
46
8.1k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
190
Navigating Weather and Climate Data
rabernat
0
180
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Designing Experiences People Love
moore
143
24k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
sira's awesome portfolio website redesign presentation
elsirapls
0
230
Fireside Chat
paigeccino
42
3.9k
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