Appearance
Fresh
Run tests
Back
Testing Quarkus applications with Testcontainers
Learn how to create a Quarkus REST API with Hibernate ORM with Panache and PostgreSQL, then test it using Quarkus Dev Services, Testcontainers, and REST Assured.
Java Testing with Docker
25 minutes
Run tests and next steps
Copy as Markdown
Open MarkdownAsk Docs AIClaudeOpen in Claude
Table of contents
Run the tests
console
$ ./mvnw testOr with Gradle:
console
$ ./gradlew testYou should see the PostgreSQL Docker container start and all tests pass. After the tests finish, the container stops and is removed automatically.
Run the application locally
Quarkus Dev Services automatically provisions unconfigured services in development mode. Start the Quarkus application in dev mode:
console
$ ./mvnw compile quarkus:devOr with Gradle:
console
$ ./gradlew quarkusDevDev Services starts a PostgreSQL container automatically. If you're running a PostgreSQL database on your system and want to use that instead, configure the datasource properties in src/main/resources/application.properties:
properties
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/postgres
quarkus.datasource.username=postgres
quarkus.datasource.password=postgresWhen these properties are set explicitly, Dev Services doesn't provision the database container and instead connects to the configured database.
Summary
Quarkus Dev Services improves the developer experience by automatically provisioning the required services using Testcontainers during development and testing. This guide covered:
- Building a REST API using JAX-RS with Hibernate ORM with Panache
- Testing API endpoints using REST Assured with Dev Services handling database provisioning
- Using
QuarkusTestResourceLifecycleManagerfor services not supported by Dev Services - Running the application locally with Dev Services
To learn more about Testcontainers, visit the Testcontainers overview.