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
90
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
480
Clean Tests - Scala UA
noamal
0
120
Other Decks in Programming
See All in Programming
Foundry Localでエージェント開発
seosoft
0
160
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
160
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
330
Family mrubyの進捗
kishima
1
110
業務時間外もAIに働いてもらう話
colorful12
3
10k
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
650
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.1k
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
770
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
300
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
270
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
App Intentsのビルドプロセスを支える技術
kntkymt
0
190
Featured
See All Featured
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
AI: The stuff that nobody shows you
jnunemaker
PRO
9
980
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
HDC tutorial
michielstock
2
860
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Utilizing Notion as your number one productivity tool
mfonobong
4
580
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.2k
Exploring anti-patterns in Rails
aemeredith
3
500
Believing is Seeing
oripsolob
1
210
Building Applications with DynamoDB
mza
96
7.2k
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]