Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Test-driven development with PHPUnit
Search
Oliver Klee
August 04, 2023
Programming
320
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
Testing von TYPO3-Extensions
oliverklee
0
8
Softwarequalität für öffentliche TYPO3-Extensions
oliverklee
0
65
Psychologische Sicherheit
oliverklee
0
44
Generative KI, Ethik und Nachhaltigkeit
oliverklee
0
180
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
150
Team-Management-Plattform
oliverklee
0
100
Vertrauen in Teams & Führung
oliverklee
0
340
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
67
Vertrauen in Teams & Führung
oliverklee
0
190
Other Decks in Programming
See All in Programming
オーケストレーション記述言語 Katari
yukikurage
0
160
AmebaブログはKMPから卒業します
kmars0605
0
210
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
820
気持ちぃ〜角丸 Squircle
ryu1013
0
320
Kotlinの15年とServer-Side Kotlin
n_takehata
1
160
R8 の設定見直しでアプリサイズ削減
andpad
0
220
Simple Storage Service(S3) is not simple
iwatsukayura
0
310
[2026-10-09]一枚の布で作らなくてもいい。 信頼性は「パッチワーク」で紡がれる~既存の運用と新しい可能性をつなぎ合わせてきたCREの話~
tosite
0
110
GraphQL の onError と Nullability のこれから
quramy
0
150
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
230
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
350
ジョジョの世界をXRで再現する
mofurune
0
180
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
135
10k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.3k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
320
Product Roadmaps are Hard
iamctodd
55
13k
Building an army of robots
kneath
307
47k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Evolving SEO for Evolving Search Engines
ryanjones
0
330
Designing Powerful Visuals for Engaging Learning
tmiket
1
610
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
280
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
330
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