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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Noam Almog
February 24, 2017
Programming
85
0
Share
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
470
Clean Tests - Scala UA
noamal
0
110
Other Decks in Programming
See All in Programming
自動レビューエンジンの実装と運用 ~レビューのない世界へ~
kurukuru1999
2
310
初めてのRubyKaigiはこう見えた
jellyfish700
0
410
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
160
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
420
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
6
1.3k
TSKaigi 2026 TypeScriptバックエンドのオブザーバビリティ戦略 — Datadog × NestJSの実践
taiseiyamamotoan
1
220
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
120
tsserverとは何だったのか、これからどうなるのか
nowaki28
1
440
3Dシーンの圧縮
fadis
1
580
TypeSpec で繋ぐ複数プロダクトの型安全
maroon8021
1
330
AIとRubyの静的型付け
ukin0k0
0
520
TAKTでAI駆動開発の品質を設計する
j5ik2o
4
340
Featured
See All Featured
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.3k
Marketing to machines
jonoalderson
1
5.3k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
370
HDC tutorial
michielstock
2
680
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Chasing Engaging Ingredients in Design
codingconduct
0
210
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Prompt Engineering for Job Search
mfonobong
0
330
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
160
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
190
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]