3 Steps Every TestShould Take
View Slide
About meMatheus 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 testsslow us down!
Developer happiness-meter: 🙁🐌 Slow tests
Developer happiness-meter: 😞🤔 Confusing tests🐌 Slow tests
Flaky testsDeveloper happiness-meter: 😠🤔 Confusing tests🐌 Slow tests
Flaky testsDeveloper 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 objectsDefine function inputs
📝 1. Setup🏋 2. Exercise
📝 1. Setup🏋 2. Exercise Calling methodsSaving objects to DB
📝 1. Setup🏋 2. Exercise 3. Verify
📝 1. Setup🏋 2. Exercise 3. Verify Check if the outputis the expected
📝 1. Setup 3. Verify🏋 2. Exercise💥 4. Teardown
📝 1. Setup 3. Verify🏋 2. Exercise💥 4. Teardown Undo changesRelease memoryRestore DB
📝 1. Setup🏋 2. Exercise 3. Verify💥 4. TeardownYou’re welcome!
📝 1. Setup 3. Verify🏋 2. Exercise
📝 1. Arrange 3. Assert🏋 2. Actaka
📝 1. Given 3. Then🏋 2. Whenaka
🤨 Why is this good?
Consistency
EXERCISE
Tests are self-contained.No mystery guests here
1. VerifyDeveloper confusion-meter: 🤔❓
1. Verify 2. Exercise + SetupDeveloper confusion-meter: 🥴⁉
1. Verify 2. Exercise + Setup? 3. VerifyDeveloper confusion-meter: 😵
Developer confusion-meter: 😵
Developer happiness-meter: 🥰
SPACE IS IMPORTANTDeveloper happiness-meter: 🥰
Developer happiness-meter: 😐
Good tests have4 3 steps
We need not only tests,but good tests!
We want good code andtests are code too!
That’s itFeel free to ask any question