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
290
Test-driven development with PHPUnit
Oliver Klee
August 04, 2023
Tweet
Share
More Decks by Oliver Klee
See All by Oliver Klee
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
88
Team-Management-Plattform
oliverklee
0
72
Vertrauen in Teams & Führung
oliverklee
0
260
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
44
Vertrauen in Teams & Führung
oliverklee
0
160
Testing von TYPO3-Extensions
oliverklee
0
86
Software-Qualität von Extensions automatisieren
oliverklee
1
55
Content-Synchronisierung
oliverklee
0
170
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
330
Other Decks in Programming
See All in Programming
SourceGeneratorのススメ
htkym
0
200
24時間止められないシステムを守る-医療ITにおけるランサムウェア対策の実際
koukimiura
1
110
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
140
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.9k
Fluid Templating in TYPO3 14
s2b
0
130
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
390
ノイジーネイバー問題を解決する 公平なキューイング
occhi
0
110
Apache Iceberg V3 and migration to V3
tomtanaka
0
170
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
5
760
CSC307 Lecture 09
javiergs
PRO
1
840
CSC307 Lecture 08
javiergs
PRO
0
670
Featured
See All Featured
Paper Plane
katiecoart
PRO
0
46k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
69
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
280
It's Worth the Effort
3n
188
29k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
120
A designer walks into a library…
pauljervisheath
210
24k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
117
110k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
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