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
ユーザーストーリーのレビューを自動化したみたの
bun913
1
300
疲弊しない!AWSセキュリティ統制の考え方 #devio_osakaday1
masahirokawahara
6
5.8k
エンタープライズ環境下での Active Directory の運用 TIPS
tamaiyutaro
1
1.5k
Delivering Millions of Messages within seconds @ Duolingo
pelelgrino
0
320
検証を通して見えてきたTiDBの性能特性
lycorptech_jp
PRO
5
2.5k
DevOpsDays History and my DevOps story
kawaguti
PRO
8
1.4k
Postman v10リリース後を振り返る
nagix
0
120
Microsoft Cloudで開発ライフサイクルを保護する
kkamegawa
0
140
Data and AI Governance: Existing Challenges and Emerging Trends
scotthsieh825
0
140
反実仮想機械学習とは何か
usaito
PRO
6
1.6k
入社後初めてのタスクでk8sアップグレードした話.pdf
kkato1
0
380
元インフラエンジニアに成る / Human Resources to Human Relations
bobtani
2
740
Featured
See All Featured
Web Components: a chance to create the future
zenorocha
304
41k
A designer walks into a library…
pauljervisheath
199
23k
In The Pink: A Labor of Love
frogandcode
137
21k
The Invisible Customer
myddelton
114
12k
How STYLIGHT went responsive
nonsquared
92
4.8k
YesSQL, Process and Tooling at Scale
rocio
162
13k
The Cost Of JavaScript in 2023
addyosmani
13
3.8k
KATA
mclloyd
14
12k
Done Done
chrislema
178
15k
Testing 201, or: Great Expectations
jmmastey
27
6.3k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
19
1.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
39
4.4k
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