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
Clean and Quality Unit Tests
Search
codecleaner
November 23, 2013
Technology
3
550
Clean and Quality Unit Tests
Talk about readability and high quality of unit tests written in PHPUnit
codecleaner
November 23, 2013
Tweet
Share
Other Decks in Technology
See All in Technology
[Keynote] What do you need to know about DevEx in 2025
salaboy
0
170
BI ツールはもういらない?Amazon RedShift & MCP Server で試みる新しいデータ分析アプローチ
cdataj
0
150
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
3k
ガバメントクラウドの概要と自治体事例(名古屋市)
techniczna
2
240
社内報はAIにやらせよう / Let AI handle the company newsletter
saka2jp
8
1.4k
Claude Codeを駆使した初めてのiOSアプリ開発 ~ゼロから3週間でグローバルハッカソンで入賞するまで~
oikon48
2
700
「使い方教えて」「事例教えて」じゃもう遅い! Microsoft 365 Copilot を触り倒そう!
taichinakamura
0
380
小学4年生夏休みの自由研究「ぼくと Copilot エージェント」
taichinakamura
0
700
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
8.8k
能登半島地震において デジタルができたこと・できなかったこと
ditccsugii
0
190
技育祭2025【秋】 企業ピッチ/登壇資料(高橋 悟生)
hacobu
PRO
0
100
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
14k
Featured
See All Featured
4 Signs Your Business is Dying
shpigford
185
22k
Gamification - CAS2011
davidbonilla
81
5.5k
Practical Orchestrator
shlominoach
190
11k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
8
910
Being A Developer After 40
akosma
91
590k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
30
2.9k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
870
Rebuilding a faster, lazier Slack
samanthasiow
84
9.2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.2k
How STYLIGHT went responsive
nonsquared
100
5.8k
The Illustrated Children's Guide to Kubernetes
chrisshort
49
51k
Become a Pro
speakerdeck
PRO
29
5.5k
Transcript
Clean & Quality unit tests
Wojtek Zieliński @codecleaner
• Names matters • Exceptions • Test Doubles • Stubbing
Collections • Arrange Act Assert What’s it all about?
Names matters
None
None
None
None
None
None
None
None
Test a single concept in each test function Robert C.
Martin
None
None
None
None
None
None
None
None
None
None
Exceptions
None
None
None
None
None
None
None
None
None
None
None
None
Test Doubles
None
None
None
How does getMock() really work? • Does Configuration class exist?
• Create Mock_Configuration_123abc class extends Configuration class • Create instance of that class • Return instance
How does getMock() really work? • Does Configuration class exist?
• Create Mock_Configuration_123abc class extends Configuration class • Create instance of that class • Return instance • Create Configuration class
None
None
None
None
None
None
None
None
None
None
None
None
Stubs provide canned answers to calls made during the test
"Mocks Aren’t Stubs" Martin Fowler
Mocks are objects pre-programmed with expectations which form a specification
of the calls they are expected to receive "Mocks Aren’t Stubs" Martin Fowler
None
None
None
None
None
None
None
None
None
None
None
None
Stubbing collections
None
None
Arrange Act Assert
None
None
None
It’s all about readability
None
None
What’s next?
None
None
Questions? Wojtek Zieliński @codecleaner