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
340
Test-driven development with PHPUnit
Oliver Klee
August 05, 2022
Tweet
Share
More Decks by Oliver Klee
See All by Oliver Klee
Team-Management-Plattform
oliverklee
0
17
Vertrauen in Teams & Führung
oliverklee
0
120
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
7
Vertrauen in Teams & Führung
oliverklee
0
82
Testing von TYPO3-Extensions
oliverklee
0
16
Software-Qualität von Extensions automatisieren
oliverklee
1
10
Content-Synchronisierung
oliverklee
0
88
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
220
Motivationspsychologie und Gamification in Non-Profit-Organisationen
oliverklee
0
120
Other Decks in Programming
See All in Programming
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
360
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
180
バグを見つけた?それAppleに直してもらおう!
uetyo
0
190
オニオンアーキテクチャを使って、 Unityと.NETでコードを共有する
soi013
0
260
nekko cloudにおけるProxmox VE利用事例
irumaru
3
480
MCP with Cloudflare Workers
yusukebe
2
230
Recoilを剥がしている話
kirik
5
7.4k
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
200
DevFest - Serverless 101 with Google Cloud Functions
tunmise
0
130
Online-Dokumentation, die hilft: Strukturen, Prozesse, Tools
ahus1
0
100
Androidアプリのモジュール分割における:x:commonを考える
okuzawats
1
230
return文におけるstd::moveについて
onihusube
1
1.3k
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
We Have a Design System, Now What?
morganepeng
51
7.3k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
The Language of Interfaces
destraynor
155
24k
Fireside Chat
paigeccino
34
3.1k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
A designer walks into a library…
pauljervisheath
205
24k
Raft: Consensus for Rubyists
vanstee
137
6.7k
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