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
270
Test-driven development with PHPUnit
Oliver Klee
August 04, 2023
Tweet
Share
More Decks by Oliver Klee
See All by Oliver Klee
Team-Management-Plattform
oliverklee
0
55
Vertrauen in Teams & Führung
oliverklee
0
210
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
28
Vertrauen in Teams & Führung
oliverklee
0
140
Testing von TYPO3-Extensions
oliverklee
0
53
Software-Qualität von Extensions automatisieren
oliverklee
1
43
Content-Synchronisierung
oliverklee
0
140
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
290
Motivationspsychologie und Gamification in Non-Profit-Organisationen
oliverklee
0
170
Other Decks in Programming
See All in Programming
Reading Rails 1.0 Source Code
okuramasafumi
0
260
MCPでVibe Working。そして、結局はContext Eng(略)/ Working with Vibe on MCP And Context Eng
rkaga
5
2.4k
複雑なフォームに立ち向かう Next.js の技術選定
macchiitaka
3
850
大規模アプリにおけるXcode Previews実用化までの道のり
ikesyo
0
290
Learn CPU architecture with Assembly
akkeylab
1
120
AI Coding Agentのセキュリティリスク:PRの自己承認とメルカリの対策
s3h
0
250
プロパティベーステストによるUIテスト: LLMによるプロパティ定義生成でエッジケースを捉える
tetta_pdnt
0
6.5k
Deep Dive into Kotlin Flow
jmatsu
1
390
GitHubとGitLabとAWS CodePipelineでCI/CDを組み比べてみた
satoshi256kbyte
4
250
LLMとPlaywright/reg-suitを活用した jQueryリファクタリングの実際
kinocoboy2
1
210
テストコードはもう書かない:JetBrains AI Assistantに委ねる非同期処理のテスト自動設計・生成
makun
0
630
HTMLの品質ってなんだっけ? “HTMLクライテリア”の設計と実践
unachang113
4
3k
Featured
See All Featured
Raft: Consensus for Rubyists
vanstee
140
7.1k
Faster Mobile Websites
deanohume
309
31k
Code Reviewing Like a Champion
maltzj
525
40k
Gamification - CAS2011
davidbonilla
81
5.4k
Speed Design
sergeychernyshev
32
1.1k
Writing Fast Ruby
sferik
628
62k
Done Done
chrislema
185
16k
Testing 201, or: Great Expectations
jmmastey
45
7.7k
Producing Creativity
orderedlist
PRO
347
40k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
KATA
mclloyd
32
14k
Navigating Team Friction
lara
189
15k
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