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
3 Steps Every Test Should Take
Search
Matheus Richard
May 27, 2021
Programming
0
78
3 Steps Every Test Should Take
Matheus Richard
May 27, 2021
Tweet
Share
More Decks by Matheus Richard
See All by Matheus Richard
The Fast Lane: Asynchronous Rails
matheusrich
0
35
Build in Private
matheusrich
0
64
Start TDDing in 5 minutes
matheusrich
0
97
Taming God Objects: easy, incremental and secure
matheusrich
1
95
Stimulus 2.0-alpha - What's new?
matheusrich
0
49
BEM - A simple CSS methodology
matheusrich
0
48
De Repente 7
matheusrich
0
12
Other Decks in Programming
See All in Programming
Gemini CLIの"強み"を知る! Gemini CLIとClaude Codeを比較してみた!
kotahisafuru
2
620
Advanced Micro Frontends: Multi Version/ Framework Scenarios
manfredsteyer
PRO
0
120
オンコール⼊⾨〜ページャーが鳴る前に、あなたが備えられること〜 / Before The Pager Rings
yktakaha4
2
1.2k
[SRE NEXT] 複雑なシステムにおけるUser Journey SLOの導入
yakenji
1
850
TypeScriptでDXを上げろ! Hono編
yusukebe
3
890
QA x AIエコシステム段階構築作戦
osu
0
220
大規模FlutterプロジェクトのCI実行時間を約8割削減した話
teamlab
PRO
0
150
No Install CMS戦略 〜 5年先を見据えたフロントエンド開発を考える / no_install_cms
rdlabo
0
390
なぜあなたのオブザーバビリティ導入は頓挫するのか
ryota_hnk
4
520
AI Ramen Fight
yusukebe
0
120
Understanding Kotlin Multiplatform
l2hyunwoo
0
240
Prompt Engineeringの再定義「Context Engineering」とは
htsuruo
0
110
Featured
See All Featured
Balancing Empowerment & Direction
lara
1
510
How to Ace a Technical Interview
jacobian
278
23k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
530
The Cost Of JavaScript in 2023
addyosmani
51
8.7k
Visualization
eitanlees
146
16k
Done Done
chrislema
185
16k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Testing 201, or: Great Expectations
jmmastey
43
7.6k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.1k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
21k
The Straight Up "How To Draw Better" Workshop
denniskardys
235
140k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Transcript
3 Steps Every Test Should Take
About me Matheus Richard
This is a ⚡lightning talk⚡, so I’m gonna go FAST
💨
🧪 Tests
😄 Tests are good! They make us more productive. Right?
❌ WRONG!
✔Good tests are good
🐢 Poorly written tests slow us down!
Developer happiness-meter: 🙁 🐌 Slow tests
Developer happiness-meter: 😞 🤔 Confusing tests 🐌 Slow tests
Flaky tests Developer happiness-meter: 😠 🤔 Confusing tests 🐌
Slow tests
Flaky tests Developer happiness-meter: 🤬 🤔 Confusing tests 📦
Brittle tests 🐌 Slow tests
🐌 Slow tests Flaky tests 📦 Brittle tests 🤔
Confusing tests
Good tests tell a story
The story has 4 acts
📝 1. Setup
📝 1. Setup Create objects Define function inputs
📝 1. Setup 🏋 2. Exercise
📝 1. Setup 🏋 2. Exercise Calling methods Saving objects
to DB
📝 1. Setup 🏋 2. Exercise 3. Verify
📝 1. Setup 🏋 2. Exercise 3. Verify Check
if the output is the expected
📝 1. Setup 3. Verify 🏋 2. Exercise 💥
4. Teardown
📝 1. Setup 3. Verify 🏋 2. Exercise 💥
4. Teardown Undo changes Release memory Restore DB
📝 1. Setup 🏋 2. Exercise 3. Verify 💥
4. Teardown You’re welcome!
📝 1. Setup 3. Verify 🏋 2. Exercise
📝 1. Arrange 3. Assert 🏋 2. Act aka
📝 1. Given 3. Then 🏋 2. When aka
None
None
None
🤨 Why is this good?
Consistency
None
None
None
None
E X E R C I S E
Tests are self-contained. No mystery guests here
None
1. Verify Developer confusion-meter: 🤔❓
1. Verify 2. Exercise + Setup Developer confusion-meter: 🥴⁉
1. Verify 2. Exercise + Setup? 3. Verify Developer confusion-meter:
😵
Developer confusion-meter: 😵
Developer happiness-meter: 🥰
SPACE IS IMPORTANT Developer happiness-meter: 🥰
Developer happiness-meter: 😐
Developer happiness-meter: 🥰
Good tests have 4 3 steps
📝 1. Setup
📝 1. Setup 🏋 2. Exercise
📝 1. Setup 3. Verify 🏋 2. Exercise
We need not only tests, but good tests!
We want good code and tests are code too!
That’s it Feel free to ask any question