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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Oliver Klee
August 05, 2022
Programming
0
400
Test-driven development with PHPUnit
Oliver Klee
August 05, 2022
Tweet
Share
More Decks by Oliver Klee
See All by Oliver Klee
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
96
Team-Management-Plattform
oliverklee
0
73
Vertrauen in Teams & Führung
oliverklee
0
290
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
46
Vertrauen in Teams & Führung
oliverklee
0
160
Testing von TYPO3-Extensions
oliverklee
0
88
Software-Qualität von Extensions automatisieren
oliverklee
1
57
Content-Synchronisierung
oliverklee
0
170
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
340
Other Decks in Programming
See All in Programming
エラーログのマスキングの仕組みづくりに役立ったASTの話
kumoichi
0
110
浮動小数の比較について
kishikawakatsumi
0
380
Rubyと楽しいをつくる / Creating joy with Ruby
chobishiba
0
200
Claude Code の Skill で複雑な既存仕様をすっきり整理しよう
yuichirokato
1
290
AWS Infrastructure as Code の新機能 2025 総まとめ 〜SA 4人による怒涛のデモ祭り〜
konokenj
10
3.2k
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
230
Head of Engineeringが現場で回した生産性向上施策 2025→2026
gessy0129
0
210
LangChain4jとは一味違うLangChain4j-CDI
kazumura
1
150
今、アーキテクトとして 品質保証にどう関わるか
nealle
0
200
ベクトル検索のフィルタを用いた機械学習モデルとの統合 / python-meetup-fukuoka-06-vector-attr
monochromegane
2
320
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
0
220
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
230
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
How to Think Like a Performance Engineer
csswizardry
28
2.5k
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
The Cost Of JavaScript in 2023
addyosmani
55
9.7k
So, you think you're a good person
axbom
PRO
2
1.9k
First, design no harm
axbom
PRO
2
1.1k
Abbi's Birthday
coloredviolet
2
5.1k
Done Done
chrislema
186
16k
Testing 201, or: Great Expectations
jmmastey
46
8.1k
Bash Introduction
62gerente
615
210k
Speed Design
sergeychernyshev
33
1.6k
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