Geek Culture
Published in

Geek Culture

Write an Integration test, not a Unit test

As a lazy software engineer I want to write code only when necessary. If I happen to write code I want to utilise it as much as possible. If this sounds like you, then let’s look at how Integration tests can allow your code to be more efficient.

Too Long To Read

Write both, Integration and Unit tests, when you have enough time or it’s a critical piece of your system. Write Integration tests first when time is off the essence.


Integration test — is a type of software testing in which the different units, modules or components of a software application are tested as a combined entity.

Unit test proves correct work of one unit only. Whereas an Integration test proves work of more than one unit.

System Under Test

Why is it important to understand what is System Under Test? It will help us define the efficient test.

System under test (SUT) — system that is being tested for correct operation.

It’s normal that Integration test covers wider SUT than a Unit test. Let’s consider the following test:

Integration test

The SUT for the test above is the whole journey of a request in a web service. Depending on our assertions we can catch a potential issue in all layers of this web service.

System Under Test: Controller, Service, Repository and Database

Here is how a Unit test might look for Controller in a web service:

Unit test
System Under Test: Controller

As we can see, Integration tests cover wider SUT than Unit tests with similar amount of code.

Bottom Line

Writing a proper Integration is challenging as it requires initial set up. Yet it pays off with time. Invest your time at the beginning and get a sense of stability about your code later.

Here is how you can ensure you’re writing an integration test:

🗄️ Use a test instance of database, a test tenant in an external dependency etc.

🖥️ Use test servers instead of mocking and stabbing.

🐳 Use Docker for easier dependency management.


  1. My example of an Integration test. Refer to the README for instructions of how to run it.
  2. Mermaid digram editor: Diagram as a Code.




A new tech publication by Start it up (

Recommended from Medium

How To Use Method Arguments In Ruby

A Year of Developer Relations

Big Names with Select Pieces of the IoT Puzzle

Open-source CMS developed in early versions of PHP

Amazon Web Services: case study of Domino’s Pizza Enterprises

Why Use Excel and Why Not

Table creation in SAP ABAP

Spark Streaming Basic Concepts -2 , Transformations 譯

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alex Kondrashov

Alex Kondrashov

Team Lead at Kyckr; Writing about my experience as a software engineer

More from Medium

Building a Platform: Part 2

Accessing Mongo Atlas using an AWS IAM Role locally

Build a Placeholder API With the New ASP.NET Core Minimal API

Build a microservices system from scratch — commit 7