This Quarkus project uses docker-compose 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. The test-classes are normal JUnit5 tests without the Quarkus annotations @QuarkusTest
and @NativeImageTest
.
This mechanism addresses an integration-test szenario 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.
For these integration-tests i have some additional Maven plugins in place:
docker-compose-maven-plugin:up
- start the whole integration-test environmentawait-maven-plugin:Await
- wait until the Quarkus health endpoint is UPmaven-failsafe-plugin:integration-test
- run all integration tests (*IT.java)docker-compose-maven-plugin:down
- stop the integration-test environmentmaven-failsafe-plugin:verify
- verify the test-results
-
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
-
Change inside docker-compose.yml the
dockerfile
property of the app service toDockerfile.jvm
-
Build and start the environment
mvn package && docker-compose up --build
-
Use VSCode test-runner to run the tests against the environment
mvn verify
can be used at any buildpipeline 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.