This example shows how integration testing with SpringBoot 2, Kotlin and Elasticsearch can be accomplished using Docker.
- Java 11
- Maven >= 3.2.1
Maven test phase will apply all unit tests - in this demo UserTest.kt and UserRepositoryMockTest
mvn clean test
Maven verify phase will apply all unit tests and all integration tests - in this demo UserTest.kt, UserRepositoryMockTest and UserRepositoryIT.kt
mvn clean verify
Maven package phase will build a local artifact and applies only unit tests
mvn clean package
Maven install phase will build an artifact, install it to local repository and applies unit and integration tests. Skipping tests will not skip starting an elasticsearch docker container.
mvn clean install
Debugging by an IDE will not start an elasticsearch container. The test container must be installed and started by yourself.
To reduce resources, it is suggested that the container be launched in Developing mode
docker pull docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.4
docker run -p 9200:9200 -p 9300:9300 --name it-elasticsearch -e "discovery.type=single-node" -e "xpack.security.enabled=false" docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.4
docker start it-elasticsearch
docker stop it-elasticsearch