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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Oliver Klee
August 04, 2023
Programming
0
300
Test-driven development with PHPUnit
Oliver Klee
August 04, 2023
Tweet
Share
More Decks by Oliver Klee
See All by Oliver Klee
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
99
Team-Management-Plattform
oliverklee
0
73
Vertrauen in Teams & Führung
oliverklee
0
300
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
51
Vertrauen in Teams & Führung
oliverklee
0
160
Testing von TYPO3-Extensions
oliverklee
0
89
Software-Qualität von Extensions automatisieren
oliverklee
1
59
Content-Synchronisierung
oliverklee
0
170
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
340
Other Decks in Programming
See All in Programming
Codex の「自走力」を高める
yorifuji
0
1.3k
PHP でエミュレータを自作して Ubuntu を動かそう
m3m0r7
PRO
2
140
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
370
AI 開発合宿を通して得た学び
niftycorp
PRO
0
170
Java 21/25 Virtual Threads 소개
debop
0
280
ポーリング処理廃止によるイベント駆動アーキテクチャへの移行
seitarof
3
1.3k
Xdebug と IDE による デバッグ実行の仕組みを見る / Exploring-How-Debugging-Works-with-Xdebug-and-an-IDE
shin1x1
0
150
Claude Code Skill入門
mayahoney
0
440
Fundamentals of Software Engineering In the Age of AI
therealdanvega
2
290
Angular-Apps smarter machen mit Gen AI: Lokal und offlinefähig - Hands-on Workshop!
christianliebel
PRO
0
140
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
130
Strategy for Finding a Problem for OSS: With Real Examples
kibitan
0
110
Featured
See All Featured
Reality Check: Gamification 10 Years Later
codingconduct
0
2.1k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.1k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
250
Build your cross-platform service in a week with App Engine
jlugia
234
18k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
Between Models and Reality
mayunak
2
240
RailsConf 2023
tenderlove
30
1.4k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Designing for Timeless Needs
cassininazir
0
170
Designing Powerful Visuals for Engaging Learning
tmiket
0
300
Faster Mobile Websites
deanohume
310
31k
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