$30 off During Our Annual Pro Sale. View Details »
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
280
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
76
Team-Management-Plattform
oliverklee
0
64
Vertrauen in Teams & Führung
oliverklee
0
240
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
38
Vertrauen in Teams & Führung
oliverklee
0
150
Testing von TYPO3-Extensions
oliverklee
0
75
Software-Qualität von Extensions automatisieren
oliverklee
1
52
Content-Synchronisierung
oliverklee
0
160
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
320
Other Decks in Programming
See All in Programming
ゆくKotlin くるRust
exoego
1
110
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
4
950
新卒エンジニアのプルリクエスト with AI駆動
fukunaga2025
0
230
TUIライブラリつくってみた / i-just-make-TUI-library
kazto
1
400
リリース時」テストから「デイリー実行」へ!開発マネージャが取り組んだ、レガシー自動テストのモダン化戦略
goataka
0
130
LT資料
t3tra
6
960
複数人でのCLI/Infrastructure as Codeの暮らしを良くする
shmokmt
5
2.3k
Giselleで作るAI QAアシスタント 〜 Pull Requestレビューに継続的QAを
codenote
0
250
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
440
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
140
非同期処理の迷宮を抜ける: 初学者がつまづく構造的な原因
pd1xx
1
740
AtCoder Conference 2025「LLM時代のAHC」
imjk
2
540
Featured
See All Featured
Discover your Explorer Soul
emna__ayadi
2
1k
How to Talk to Developers About Accessibility
jct
1
81
How STYLIGHT went responsive
nonsquared
100
6k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.7k
Optimizing for Happiness
mojombo
379
70k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
250
Building the Perfect Custom Keyboard
takai
1
660
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
The Curious Case for Waylosing
cassininazir
0
190
Evolving SEO for Evolving Search Engines
ryanjones
0
72
The World Runs on Bad Software
bkeepers
PRO
72
12k
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