Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
3 Steps Every Test Should Take
Matheus Richard
May 27, 2021
Programming
0
12
3 Steps Every Test Should Take
Matheus Richard
May 27, 2021
Tweet
Share
More Decks by Matheus Richard
See All by Matheus Richard
Start TDDing in 5 minutes
matheusrich
0
27
Taming God Objects: easy, incremental and secure
matheusrich
1
45
Stimulus 2.0-alpha - What's new?
matheusrich
0
25
BEM - A simple CSS methodology
matheusrich
0
19
De Repente 7
matheusrich
0
2
Other Decks in Programming
See All in Programming
Introduction to Property-Based Testing @ COSCUP 2022
cybai
1
150
Scaling Productivity- How we have improved our dev experience
sockeqwe
1
120
Edge Side Frontend という新領域
mizchi
22
10k
夕食断食にTRY!/for-lt-12th
pachikuriii
0
230
サーバーレスパターンから学ぶデータ分析基盤構築 / devio2022
kasacchiful
0
480
FargateとAthenaで作る、機械学習システム
nayuts
0
170
Regular expressions basics/正規表現の基本
kishikawakatsumi
6
260
Pythonで鉄道指向プログラミング
usabarashi
0
130
atama plusの開発チームはどのように「不確実性」に向き合ってきたか〜2022夏版〜
atamaplus
3
610
NestJS_meetup_atamaplus
atamaplus
0
210
FullStack eXchange, July 2022
brucel
0
200
ESM移行は無理だけどおれもSindreのライブラリが使いたい!
sosukesuzuki
2
540
Featured
See All Featured
Clear Off the Table
cherdarchuk
79
290k
Done Done
chrislema
174
14k
The Illustrated Children's Guide to Kubernetes
chrisshort
18
40k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
236
1.1M
No one is an island. Learnings from fostering a developers community.
thoeni
9
1.3k
Bash Introduction
62gerente
598
210k
The MySQL Ecosystem @ GitHub 2015
samlambert
239
11k
GitHub's CSS Performance
jonrohan
1020
420k
Rebuilding a faster, lazier Slack
samanthasiow
62
7.3k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
6
560
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
7
1.1k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
11
4.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