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 04, 2023
Programming
300
0
Share
Test-driven development with PHPUnit
Oliver Klee
August 04, 2023
More Decks by Oliver Klee
See All by Oliver Klee
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
100
Team-Management-Plattform
oliverklee
0
76
Vertrauen in Teams & Führung
oliverklee
0
300
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
52
Vertrauen in Teams & Führung
oliverklee
0
160
Testing von TYPO3-Extensions
oliverklee
0
91
Software-Qualität von Extensions automatisieren
oliverklee
1
61
Content-Synchronisierung
oliverklee
0
180
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
350
Other Decks in Programming
See All in Programming
Cache-moi si tu peux : patterns et pièges du cache en production - Devoxx France 2026 - Conférence
slecache
0
280
書籍「ユーザーストーリーマッピング」が私のバイブル
asumikam
4
380
GitHubCopilotCLIをはじめよう.pdf
htkym
0
200
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
110
의존성 주입과 모듈화
fornewid
0
150
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
710
2026_04_15_量子計算をパズルとして解く
hideakitakechi
0
110
Coding as Prompting Since 2025
ragingwind
0
840
AI-DLC Deep Dive
yuukiyo
9
4.4k
mruby on C#: From VM Implementation to Game Scripting (RubyKaigi 2026)
hadashia
2
570
Running Swift without an OS
kishikawakatsumi
0
850
アクセシビリティ試験の"その後"を仕組み化する
yuuumiravy
0
150
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
515
110k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
100
Git: the NoSQL Database
bkeepers
PRO
432
67k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
270
AI: The stuff that nobody shows you
jnunemaker
PRO
6
580
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Google's AI Overviews - The New Search
badams
0
980
GraphQLとの向き合い方2022年版
quramy
50
15k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
340
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
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