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
80
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
36
Build in Private
matheusrich
0
64
Start TDDing in 5 minutes
matheusrich
0
98
Taming God Objects: easy, incremental and secure
matheusrich
1
97
Stimulus 2.0-alpha - What's new?
matheusrich
0
49
BEM - A simple CSS methodology
matheusrich
0
48
De Repente 7
matheusrich
0
13
Other Decks in Programming
See All in Programming
TROCCO×dbtで実現する人にもAIにもやさしいデータ基盤
nealle
0
260
Honoアップデート 2025年夏
yusukebe
1
740
コンテキストエンジニアリングで変わるAI活用 リファクタリングワークフローの実践から学んだ形式知
leveragestech
0
100
WebAssemblyインタプリタを書く ~Component Modelを添えて~
ruccho
1
860
decksh - a little language for decks
ajstarks
4
21k
Claude Code と OpenAI o3 で メタデータ情報を作る
laket
0
130
JetBrainsのAI機能の紹介 #jjug
yusuke
0
210
Understanding Ruby Grammar Through Conflicts
yui_knk
1
110
DataformでPythonする / dataform-de-python
snhryt
0
180
GUI操作LLMの最新動向: UI-TARSと関連論文紹介
kfujikawa
0
970
Understanding Kotlin Multiplatform
l2hyunwoo
0
260
エンジニアのための”最低限いい感じ”デザイン入門
shunshobon
0
110
Featured
See All Featured
A designer walks into a library…
pauljervisheath
207
24k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
A better future with KSS
kneath
239
17k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
770
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.4k
How to train your dragon (web standard)
notwaldorf
96
6.2k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Git: the NoSQL Database
bkeepers
PRO
431
65k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
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