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 Tests
Search
Noam Almog
February 24, 2017
Programming
0
75
Clean Tests
Clean test presentation,
Kiev JUG, 23.2.17
Noam Almog
February 24, 2017
Tweet
Share
More Decks by Noam Almog
See All by Noam Almog
Rapid Development with Microservices
noamal
0
450
Clean Tests - Scala UA
noamal
0
110
Other Decks in Programming
See All in Programming
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
440
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.3k
AIエージェントの設計で注意するべきポイント6選
har1101
7
3.4k
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
6
1.9k
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
AI時代の認知負荷との向き合い方
optfit
0
140
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.3k
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
620
Grafana:建立系統全知視角的捷徑
blueswen
0
320
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
5.9k
Fluid Templating in TYPO3 14
s2b
0
130
Implementation Patterns
denyspoltorak
0
280
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Docker and Python
trallard
47
3.7k
GraphQLの誤解/rethinking-graphql
sonatard
74
11k
The Pragmatic Product Professional
lauravandoore
37
7.1k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
270
Thoughts on Productivity
jonyablonski
74
5k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
0
100
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
0
1.8k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
120
4 Signs Your Business is Dying
shpigford
187
22k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.9k
Transcript
Clean Tests Noam Almog | Tech Lead linkedin github.com/noam-almog @NoamSon
[email protected]
Hi. Tech Lead Wix.com Noam Almog
AGENDA Intro Review Test Structures Refactor each part of the
test Conclude
Should I Clean ? § Test lasts More than production
Code. § More Lines of code § Read and reviewed More
If you let the tests rot, then your code will
rot too “ “ Robert C. Martin
What Is ”Good” ? § How easy is it to
extend it ? § When break, is it easy to fix ? § How many “Rewrite” calls ?
Test Structure 01
Test Structure § Test is a Map to your code.
§ Reveille the right amount of details. § Should be Consistent (*)
Test Structure
From Testing Code to Testing Behavior
Structure Pitfalls Test only one thing
Structure Pitfalls Hide Too Much Data
Send Mail invoke
New Test 01
Test Description § Use Plain English § Use Simple Language
– Not Code ! § Find a sentence structure § “throw an exception if user does not exist” § “send an email to the the email registered with the site-id”
Test Description Does not Compile
Test Setup 02
Can A Single Test Case Stand on His own
Extract Setup to Methods § Select method name that implies
structure § Starts with given § Contain the collaborator name § Describe the defined Behavior § Reverse the order of parameters § Use parameter names to show what is important
Describe the What are testing, NOT How you are testing
Simplify The Code § Do not use concrete values in
the test. § Reduce number of moving parts § Do not move important logic out of the scope
Extract Drivers § Move all setup method to it §
Move all related variables to it § Split according to the Subject
When is a good time to start ? Now !
Test Action 03
Test Action § Should be a single statement § Do
NOT hide !
Test Expectations 04
Matchers, Why ? § Readable § Better Failure Messages §
Reusable and Flexible
Matcher libraries § Hamcrest (Java) § Chai (JS) § Specs2/ScalaTest
(Scala)
Match Expectations § Use just one matcher § Describe what
you are matching, now how § Don’t define any new variables
Use Only what You Defined
Failure Messages Can you tell me why this failed ?
Conclusion § Test behavior and not code § Test Should
stand on his own § Describe what and not how § Start today, don’t wait for tomorrow § Use only variables you defined
Thank You linkedin github.com/noam-almog @NoamSon
[email protected]
Q&A linkedin github.com/noam-almog @NoamSon
[email protected]