Are unit tests worth it?

In the realm of software, unit tests are like unsung heroes. They quietly play a crucial role, ensuring that each part of the code, or each “atomic unit,” behaves as it should. 

Let’s dive a bit deeper into this concept, keeping things simple and relatable. Imagine we’re talking about a car.

Unit Tests: Checking the Basics

Consider a car. It’s made up of various parts, each with a specific function. In unit tests, we focus on these individual parts separately. We’re not concerned with how they interact, but rather, we want to make sure each part is doing its job correctly.

For instance, we might have two separate unit tests for a car:

  • One that checks if the engine is working properly.
  • Another that ensures the window fits perfectly in the door.

Integration Tests: The Interaction Game

Moving on to integration tests, this is where we see how well the different parts play together.

Sticking with our car analogy, an integration test might check whether you can smoothly open the window while the engine is running

It’s like making sure the various components of the car cooperate well, ensuring a smooth ride (or in our case, smooth code execution).

Upgrades and Adjustments: The Test Continues

Imagine wanting to upgrade the engine of the car. Naturally, this change means that new unit tests will be necessary to ensure the revamped engine’s behavior is up to mark. 

However, the unit tests for the window remain unchanged; they continue to ensure that the window fits and operates as it should.

When Tests Fail: Unveiling Issues
If an integration test fails, it’s a clear red flag—something’s off. It’s pretty straightforward. 

But let’s consider a scenario where a unit test, say for the window, crashes unexpectedly. 

This could signal a significant issue, possibly pointing towards a problem like tight coupling in the code.

The analogy might seem a bit abstract when applied to a car, but in the software world, weird and unexpected things happen quite frequently. Understanding unit and integration tests, and their significance, helps in navigating through the complexities and weirdness that software development often presents.


To keep certain standards of the software, we need to implement all layers of the test pyramid.

more insights

Jarosław Michalik

#kotlinDevChallenge 2023 summary

The KotlinDevChallenge was not just a competition, but a journey of learning, growth, and community engagement. Every participant in this challenge is a winner in

Read More »
Jarosław Michalik

#kotlinDevChallenge – 24

What do you love most about Kotlin? Productivity increase? Idioms? Or that it isn’t Java? Maybe something else! Share it. It can be short. It

Read More »

AndroidPro newsletter 🚀

join 3057 developers reading AndroidPro newsletter every week

👉 tips & tricks, articles, videos

👉 every Thursday in your inbox

🎁 bonus on signup – Clean Architecture blueprint

brought to you by Jarek Michalik, Kotlin GDE

You can unsubscribe any time. For details visit our privacy policy.

android pro newsletter tips and tricks how to learn android