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
86
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
38
Build in Private
matheusrich
0
67
Start TDDing in 5 minutes
matheusrich
0
110
Taming God Objects: easy, incremental and secure
matheusrich
1
100
Stimulus 2.0-alpha - What's new?
matheusrich
0
51
BEM - A simple CSS methodology
matheusrich
0
49
De Repente 7
matheusrich
0
14
Other Decks in Programming
See All in Programming
NIKKEI Tech Talk#38
cipepser
0
350
Kotlinで実装するCPU/GPU 「協調的」パフォーマンス管理
matuyuhi
0
200
Google Opal解体新書
mickey_kubo
3
110
社会人になっても趣味開発を続けたい! / traPavilion
mazrean
1
120
Kotlin 2.2が切り拓く: コンテキストパラメータで書く関数型DSLと新しい依存管理のかたち
knih
0
120
AIのバカさ加減に怒る前にやっておくこと
blueeventhorizon
0
130
SODA - FACT BOOK(JP)
sodainc
1
9.1k
CSC305 Lecture 13
javiergs
PRO
0
330
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
650
SidekiqでAIに商品説明を生成させてみた
akinko_0915
0
110
ビルドプロセスをデバッグしよう!
yt8492
0
180
TransformerからMCPまで(現代AIを理解するための羅針盤)
mickey_kubo
7
5.9k
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
Testing 201, or: Great Expectations
jmmastey
46
7.7k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
A Modern Web Designer's Workflow
chriscoyier
697
190k
How STYLIGHT went responsive
nonsquared
100
5.9k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Why Our Code Smells
bkeepers
PRO
340
57k
How GitHub (no longer) Works
holman
315
140k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.7k
Writing Fast Ruby
sferik
630
62k
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