Integration and end-to-end testing with TestContainers and JUnit 5

by | Sep 27, 2019 | Voxxed Days Cluj-Napoca 2019

Nikolay Kuznetsov is developing microservices with Go and Kubernetes, previously with Java/Kotlin and Spring Cloud and he is working at @Zalando.

TestContainers library facilitates simple start up of a service dependencies, i.e. Postgres, Redis in throwaway Docker containers.The library works over Docker API and has a list of features which significantly improve a developer experience:

– Docker environment autodiscovery

– mapping to random unique host ports

– easy Docker network configuration and sharing

– waiting strategies for a ready status – containers cleanup guarantees

– ready to use specific containers

– JUnit 5 integration

In this talk, the above-mentioned features would be elaborated. Code samples would be discussed. In demo part integration tests for two services would be shown. They use Postgres and Redis under the hood, respectively. In another demo it would be possible to run both of the services in Docker containers at the same time together with their dependencies and to perform a simple end-to-end test.