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 05, 2022
Programming
0
280
Test-driven development with PHPUnit
Oliver Klee
August 05, 2022
Tweet
Share
More Decks by Oliver Klee
See All by Oliver Klee
Content-Synchronisierung
oliverklee
0
21
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
64
Motivationspsychologie und Gamification in Non-Profit-Organisationen
oliverklee
0
83
Test-driven development with PHPUnit
oliverklee
0
170
Writing PHPUnit tests for TYPO3 extensions
oliverklee
0
150
Software quality for TYPO3 projects: A story of cheese, games and tools
oliverklee
0
220
TDD für Senior-Devs
oliverklee
0
64
Gamification für Arbeit in Communities
oliverklee
0
110
Software quality, cheese and games
oliverklee
0
300
Other Decks in Programming
See All in Programming
大規模UIKitベースアプリへのTCAの段階的導入/gradual-adoption-of-tca-in-a-large-scale-uikit-based-app
takehilo
2
200
デフォルトにして至高、RubyMineの大好きな所
ruzia
0
760
見た目から始める生産性向上
ikumatadokoro
10
1.4k
Fragment Composition of GraphQL
quramy
13
1.4k
Java 22 Overview
kishida
1
190
Ruby GitHub Packages
bkuhlmann
0
640
サイコロで理解する統計的仮説検定の考え方
tatamiya
4
1k
Node.js v22 で変わること
yosuke_furukawa
PRO
11
3.9k
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
280
AWS CDKコントリビュートTIPS / aws-cdk-contribution-tips
gotok365
4
380
StoreKit2によるiOSのアプリ内課金のリニューアル
kangnux
0
120
大規模Reactアプリのリアーキテクチャ~8万行のTanStack Query移行の軌跡~
kj455
4
1k
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
321
23k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
21
1.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
660
120k
For a Future-Friendly Web
brad_frost
172
9k
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.7k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
126
32k
BBQ
matthewcrist
80
8.8k
Designing for humans not robots
tammielis
247
25k
Agile that works and the tools we love
rasmusluckow
325
20k
Atom: Resistance is Futile
akmur
260
25k
RailsConf 2023
tenderlove
8
550
Faster Mobile Websites
deanohume
300
30k
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