This Quarkus project uses Testcontainers with the Docker Compose Module for setting up an integration-test environment which contains:
- Postgres DB
- Kafka Broker
- Kafka Zookeeper
- Quarkus application
I'm using Mavens integration-test and verify phase to run my integration-tests against the docker-compose environment started by testcontainers. The test-classes are normal JUnit5 tests without the Quarkus annotations @QuarkusTest
and @NativeImageTest
.
This mechanism addresses an integration-test scenario where all real world components (postgres, kafka, etc. but no mocks or H2 dbs) and the application itself are in place for being tested from outside via REST calls. Without the need to deploy the whole stuff to your target cloud environment.
-
Change inside docker-compose.yml the
dockerfile
property of the app service toDockerfile.jvm
and use the jvm command -
Maven verfiy
mvn verify
-
Change inside docker-compose.yml the
dockerfile
property of the app service toDockerfile.native
and use the native command -
Maven verfiy
mvn verify -Pnative
mvn verify
can be used at any CI build-pipeline too.
- I'm using the shell-script
wait-for-it.sh
(https://github.com/jlordiales/wait-for-it) to wait with the Quarkus application start until all dependent services are up and running.