Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Clean Tests
Search
Noam Almog
February 24, 2017
Programming
91
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Clean Tests
Clean test presentation,
Kiev JUG, 23.2.17
Noam Almog
February 24, 2017
More Decks by Noam Almog
See All by Noam Almog
Rapid Development with Microservices
noamal
0
490
Clean Tests - Scala UA
noamal
0
120
Other Decks in Programming
See All in Programming
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
410
The Rails Doctrine Decade
koic
2
590
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
170
phperだってパンチカードでコーディングしたい
o0h
PRO
0
330
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.2k
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
Web Framework Benchmark Battle 2026, Any%
a_matsuda
2
2k
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
220
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
260
Jetpack Compose Mechanisms
skydoves
3
820
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
220
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
270
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
780
Mind Mapping
helmedeiros
1
400
Making the Leap to Tech Lead
cromwellryan
135
10k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Site-Speed That Sticks
csswizardry
13
1.6k
Un-Boring Meetings
codingconduct
0
460
Why Our Code Smells
bkeepers
PRO
340
58k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Building Adaptive Systems
keathley
44
3.2k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
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]