An introduction to Unit Tests (UT), Mocks, Integration Tests (IT), End-to-end Tests (E2E).

Say that you want to learn how to drive. πŸš—

[1/9]
At home, you have a car simulator.
Your Unit Tests will be:
πŸ”Έhow to turn on the car
πŸ”Έhow to speed up
πŸ”Έhow to slow down
πŸ”Έwhat to do with a red light

You are not using a real car, but a simulator. This is your *mock*.

[2/9]
UTs: test the behaviors in a controlled environment with mocks.

They are fast: you can stay at home with your simulator. In a minute you'll be able to redo your tests and add more (eg: turn on the lights)

[3/9]
Now it's time to try a real car, in a parking lot. πŸ…Ώ

Do the same actions you've seen work with a real car?

Those are Integration Tests: use real stuff, do better tests;

ITs are slower than UTs - you need a real environment, with a parking lot and a real car

[4/9]
What more do ITs add that you can't find with UTs?
For example, that the simulator used a car with automatic shift, but the real car has manual shift.

Or that you have to turn on the car before accelerating.

[5/9]
The actions you've tried with UT were all correct if performed in a "sandbox"! With ITs you put those tests together, into the real world.

[6/9]
But you're still in a parking lot.

With E2Es you put everything in practice, but this time for real.
Use a real car, on a real road, with real semaphores and other factors (traffic jams, blocked roads...)

[7/9]
E2Es are way slower than UTs, but provide you more info about a real scenario.

You will not run them for every new small thing you learn about driving. But you focus on a real scenario (eg: go to the nearest Walmart)

[8/9]
All those kinds of tests are useful in different ways. UTs are faster but in a sandboxed env. E2Es are slower but focused on real scenarios.

🐒Slow ⚑Fast
----------------------->
E2E IT UT
----------------------->
🌎Wide πŸ—œNarrow

[9/9]

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Davide Bellone 🐧 - π—°π—Όπ—±π—²πŸ°π—Άπ˜.π—±π—²π˜ƒ πŸ“ƒπŸ“ƒ

Davide Bellone 🐧 - π—°π—Όπ—±π—²πŸ°π—Άπ˜.π—±π—²π˜ƒ πŸ“ƒπŸ“ƒ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(