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
540
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
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
180
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
110
あなたの知らない Function.prototype.toString() の世界
mizdra
PRO
1
160
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
520
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
アジャイルでの品質の進化 Agile in Motion vol.1/20241118 Hiroyuki Sato
shift_evolve
0
180
アジャイルチームがらしさを発揮するための目標づくり / Making the goal and enabling the team
kakehashi
3
150
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.5k
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
210
The Rise of LLMOps
asei
8
1.7k
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
2
230
Featured
See All Featured
4 Signs Your Business is Dying
shpigford
180
21k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Being A Developer After 40
akosma
87
590k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
900
YesSQL, Process and Tooling at Scale
rocio
169
14k
The Invisible Side of Design
smashingmag
298
50k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
430
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Statistics for Hackers
jakevdp
796
220k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
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