Docker and managing Integration tests — A better approach.

Requirement 1

Requirement 2

Requirement 3

Requirement 4

My philosophy on Integration Tests


Philisophy behind the design where images have built-in sample data, and test environment set up being part of build settings:
-----------------------------------------------------------------
1) The "real" environment for "real" testing shouldn't be mutated anywhere else other than the application itself. This leads to better testing of the lifecycle of an application.
2) Multiple integration tests sharing the same environment is a tragic situation. Stop reusing. Don't be lazy.3) If you want to run concurrency tests, run multiple instances of the same application with in the same test case, with obviously a test environment completely new and not being used/mutated anywhere else.4) To trouble shoot test environment, you should be able to spin up just the test environment in isolation. A build task could be a perfect solution to do this. You are building an environment that your app is supposed to work on.5) If your integration test fails, it means you don't know about the real test environment. So come back to build configs to know more about it, and change your test cases.
  • We might have done port mappings in docker-compose files
  • There is a host machine dependency for your docker environment. An example is putting a README of what to change in /etc/hosts on running integration tests, may be to run from an IDE.

Let’s start the set up now

Step 1

addSbtPlugin("com.tapad" % "sbt-docker-compose" % "1.0.34")
addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.5.0")

Step 2

Tests.Argument(
TestFrameworks.Specs2, “include”, “DockerComposeTag”
)`

Step 3

Step 4

Step 5

Result:

Fantastic CI

sbt dockerComposeDown dockerComposeUp docker-int:test dockerComposeDown

--

--

--

A software engineer and a functional programming enthusiast at Simple-machines, Sydney, and a hardcore hiking fan. https://twitter.com/afsalt2

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

TDD: An Engineer’s Light in the Blackest Night

Introduction to FastAPI and Local DynamoDB

Building a Trivia Device with No Experience

Detecting Market Regime With the SuperTrend Indicator.

The Demarker Contrarian Indicator. A Study & Back-test in Python.

Mac Apps For Mp3

My take on programming languages

Get Eurex Trading Holidays — and more — in 5 mins using Python and GraphQL

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
Afsal Thaj

Afsal Thaj

A software engineer and a functional programming enthusiast at Simple-machines, Sydney, and a hardcore hiking fan. https://twitter.com/afsalt2

More from Medium

Kafka Dynamic Configuration & Multiple Error Handler

Apache Kafka’s 3 Main Functions

Kafka: Consume Messages From Multiple Queues

Eventbus written in Python based on Kafka