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
0
270
Test-driven development with PHPUnit
Oliver Klee
August 04, 2023
Tweet
Share
More Decks by Oliver Klee
See All by Oliver Klee
Team-Management-Plattform
oliverklee
0
54
Vertrauen in Teams & Führung
oliverklee
0
210
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
28
Vertrauen in Teams & Führung
oliverklee
0
140
Testing von TYPO3-Extensions
oliverklee
0
53
Software-Qualität von Extensions automatisieren
oliverklee
1
42
Content-Synchronisierung
oliverklee
0
140
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
280
Motivationspsychologie und Gamification in Non-Profit-Organisationen
oliverklee
0
170
Other Decks in Programming
See All in Programming
AWS発のAIエディタKiroを使ってみた
iriikeita
1
190
print("Hello, World")
eddie
2
530
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
320
JSONataを使ってみよう Step Functionsが楽しくなる実践テクニック #devio2025
dafujii
1
650
ぬるぬる動かせ! Riveでアニメーション実装🐾
kno3a87
1
230
testingを眺める
matumoto
1
140
奥深くて厄介な「改行」と仲良くなる20分
oguemon
1
600
為你自己學 Python - 冷知識篇
eddie
1
350
アルテニア コンサル/ITエンジニア向け 採用ピッチ資料
altenir
0
110
請來的 AI Agent 同事們在寫程式時,怎麼用 pytest 去除各種幻想與盲點
keitheis
0
130
250830 IaCの選定~AWS SAMのLambdaをECSに乗り換えたときの備忘録~
east_takumi
0
400
私の後悔をAWS DMSで解決した話
hiramax
4
210
Featured
See All Featured
Navigating Team Friction
lara
189
15k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.9k
Visualization
eitanlees
148
16k
Bash Introduction
62gerente
615
210k
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
Six Lessons from altMBA
skipperchong
28
4k
Writing Fast Ruby
sferik
628
62k
A Tale of Four Properties
chriscoyier
160
23k
Thoughts on Productivity
jonyablonski
70
4.8k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.9k
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