Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Test-driven development with PHPUnit
Oliver Klee
August 05, 2022
Programming
0
110
Test-driven development with PHPUnit
Oliver Klee
August 05, 2022
Tweet
Share
More Decks by Oliver Klee
See All by Oliver Klee
Gamification für Arbeit in Communities
oliverklee
0
49
Software quality, cheese and games
oliverklee
0
120
Gamification for the TYPO3 Community
oliverklee
0
120
PHP Software quality tools
oliverklee
0
140
DEVSUMMIT2022
oliverklee
0
20
Testing für TYPO3-Extensions
oliverklee
0
31
Gamification für Community-Sprints
oliverklee
0
95
Automating the code quality of your extensions
oliverklee
0
290
Dependency Hell, Composer and PHIVE
oliverklee
0
140
Other Decks in Programming
See All in Programming
監視せなあかんし、五大紙だけにオオカミってな🐺🐺🐺🐺🐺
sadnessojisan
2
1.5k
Form実装基本を学び直してみた
hyugatsukui
0
240
社会人 20 年目エンジニア、発信で技術学びなおしてる話
e99h2121
1
140
jq at the Shortcuts
cockscomb
1
440
レガシーフレームワークからの移行
ug
0
120
量子コンピュータ時代のプログラミングセミナー / 20221222_Amplify_seminar _route_optimization
fixstars
0
250
Functional Fun in Kotlin
nomisrev
1
110
23年のJavaトレンドは?Quarkusで理解するコンテナネイティブJava
tatsuya1bm
1
130
Qiita Night PHP 2023
fuwasegu
0
11k
domain層のモジュール化 / MoT TechTalk #15
mot_techtalk
0
130
AWSにおける標的型Bot対策
hacomono
0
430
Ruby Pattern Matching
bkuhlmann
0
610
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
8
3.2k
Teambox: Starting and Learning
jrom
124
7.9k
Build your cross-platform service in a week with App Engine
jlugia
221
17k
Happy Clients
brianwarren
90
5.8k
jQuery: Nuts, Bolts and Bling
dougneiner
57
6.6k
Put a Button on it: Removing Barriers to Going Fast.
kastner
56
2.5k
Web Components: a chance to create the future
zenorocha
304
40k
Fireside Chat
paigeccino
16
1.9k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
15
1.2k
BBQ
matthewcrist
75
8.1k
Mobile First: as difficult as doing things right
swwweet
213
7.8k
Designing for Performance
lara
600
65k
Transcript
Test-driven development with PHPUnit Oliver Klee, 2022-08 @oliklee
| Mastodon:
[email protected]
|
[email protected]
About me Oliver „Oli“ Klee #bonn #extension-dev #workshop-teacher #unit-testing-guy #phpstan-guy
#typo3-ombudsperson #typo3-quality-assurance-initiative #gami fi cation-working-group #game-cooking #powermetal
???
The goals ✓ You have a clearer understanding on how
TDD works. ✓(optional) You get test-infected. ✓You learn at least 1 new testing pattern. ✓We all have fun.
The travel plan 1. getting starte d 2. concepts &
term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
The rules 1. There are no stupid questions. 2. The
joker rule.
The travel plan 1. getting starte d 2. concepts &
term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
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
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();
Code test-first write test write code refactor
The travel plan 1. getting starte d 2. concepts &
term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
The travel plan 1. getting starte d 2. concepts &
term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
https://github.com/TYPO3-Documentation/tea/ Branch: workshop/t3dd22 File: Exercises.md
The travel plan 1. getting starte d 2. concepts &
term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
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
The travel plan 1. getting starte d 2. concepts &
term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback