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 04, 2023
Programming
310
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Test-driven development with PHPUnit
Oliver Klee
August 04, 2023
More Decks by Oliver Klee
See All by Oliver Klee
Generative KI, Ethik und Nachhaltigkeit
oliverklee
0
40
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
130
Team-Management-Plattform
oliverklee
0
93
Vertrauen in Teams & Führung
oliverklee
0
320
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
61
Vertrauen in Teams & Führung
oliverklee
0
180
Testing von TYPO3-Extensions
oliverklee
0
100
Software-Qualität von Extensions automatisieren
oliverklee
1
64
Content-Synchronisierung
oliverklee
0
190
Other Decks in Programming
See All in Programming
今さら聞けない .NET CLI
htkym
0
190
源内ハンズオン概要編
hideg
0
170
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
920
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
110
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
490
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
400
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
0
130
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
360
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
4
410
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
220
Go 1.27 における memory allocation の高速化
andpad
0
170
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
590
Featured
See All Featured
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.8k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Building Adaptive Systems
keathley
44
3.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Statistics for Hackers
jakevdp
799
230k
GitHub's CSS Performance
jonrohan
1033
470k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
240
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Visualization
eitanlees
152
17k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
240
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
490
Transcript
Test-driven Development with PHPUnit Oliver Klee, 2023-08 @
[email protected]
|
[email protected]
About me Oliver „Oli“ Kle e #bon n #extension-de v
#workshop-teache r #unit-testing-gu y #phpstan-gu y #best-practices-tea m #motivation-research-tea m #team-leadership-working-grou p #game-cookin g #powermetal
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, PHP
or Symfony 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();
4 test phases set up setUp() code in the test
method exercise method call verify assert…() tear down tearDown()
Code test-first write test write code refactor
Effects of TDD higher code coverage minimale code think
before you code tests now test what the code should do (instead of what it does) focused coding cleaner code structure
Test levels http:// fi lipdefar.com/2015/06/tested-be-thy-name.html
Unit tests are small and fast
Integration tests test how components work together in TYPO3:
„functional tests“
Acceptance tests Codeception Cypress
Test types
Blackbox tests test the public API
Whitebox tests inner workings test the
Anti- zombie tests-
Regression tests
Smoke tests
Smoke tests
Story tests for Behavior-driven developmen t (BDD) Behat Codeception
The testing pyramid Unit Functional/ Integration Acceptance Photo by Eugene
Tkachenko on Unsplash: https://unsplash.com/photos/TF47p5PHW18
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