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
47
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
5
Build in Private
matheusrich
0
17
Start TDDing in 5 minutes
matheusrich
0
84
Taming God Objects: easy, incremental and secure
matheusrich
1
68
Stimulus 2.0-alpha - What's new?
matheusrich
0
39
BEM - A simple CSS methodology
matheusrich
0
41
De Repente 7
matheusrich
0
8
Other Decks in Programming
See All in Programming
Code Reviews
bkuhlmann
4
870
1인 개발자로 행복하게 살기 - GDG 송도 헬로월드 2024
benjaminkim
1
5.6k
SwiftUI Performance 不要なViewの再描画と更新を抑える
bigamitiongit
1
150
Elm 0.19.0 Changes
bkuhlmann
0
480
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
400
VSCodeでのDatabricks開発もお勧めしたい/I would also recommend Databricks development with VSCode.
kazumain
0
230
Semantic search with Django and pgvector
pauloxnet
0
230
ONE WEDGE_company_guide
1wedge_one
0
340
Git Rebase
bkuhlmann
11
1.6k
From Spring Boot 2 to Spring Boot 3 with Java 22 and Jakarta EE
ivargrimstad
0
850
脱・初心者!脱・マネコン!AWS CDKを使ってみませんか!?
har1101
0
300
pixivアプリでマルチモジュールを実現するまで
gatosyocora
1
130
Featured
See All Featured
Facilitating Awesome Meetings
lara
40
5.6k
Bootstrapping a Software Product
garrettdimon
PRO
301
110k
Debugging Ruby Performance
tmm1
69
11k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
1
1.3k
Being A Developer After 40
akosma
56
580k
What's in a price? How to price your products and services
michaelherold
237
11k
Build The Right Thing And Hit Your Dates
maggiecrowley
23
2k
Stop Working from a Prison Cell
hatefulcrawdad
265
19k
Writing Fast Ruby
sferik
619
60k
The Cost Of JavaScript in 2023
addyosmani
13
3.8k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
16k
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