$30 off During Our Annual Pro Sale. View Details »
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
MAP-7thplaceSolution
yukichi0403
2
250
M5UnifiedとPicoRubyで楽しむM5シリーズ
kishima
0
110
“決まらない”NSM設計への処方箋 〜ビットキーにおける現実的な指標デザイン事例〜 / A Prescription for "Stuck" NSM Design: Bitkey’s Practical Case Study
bitkey
PRO
1
340
Digitization部 紹介資料
sansan33
PRO
1
6.1k
Design System Documentation Tooling 2025
takanorip
1
930
Multimodal AI Driving Solutions to Societal Challenges
keio_smilab
PRO
1
120
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
3.3k
生成AI・AIエージェント時代、データサイエンティストは何をする人なのか?そして、今学生であるあなたは何を学ぶべきか?
kuri8ive
2
1.8k
AI/MLのマルチテナント基盤を支えるコンテナ技術
pfn
PRO
5
720
AI時代の開発フローとともに気を付けたいこと
kkamegawa
0
160
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
9.9k
Claude Code Getting Started Guide(en)
oikon48
0
140
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
135
9.6k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
The World Runs on Bad Software
bkeepers
PRO
72
12k
The Invisible Side of Design
smashingmag
302
51k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
GraphQLとの向き合い方2022年版
quramy
50
14k
The Cost Of JavaScript in 2023
addyosmani
55
9.3k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.1k
Six Lessons from altMBA
skipperchong
29
4.1k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
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