When using Testcontainers with Quarkus, the standard JUnit 5 @Testcontainers extension conflicts with @QuarkusTest, making it difficult to pass randomly assigned container ports into the Quarkus bootstrap process. A cleaner solution is to use Quarkus' built-in test resources via the QuarkusTestResourceLifecycleManager interface, which manages container lifecycle and injects configuration properties (like the datasource URL with the random port) before tests run. A bonus tip covers handling database schema creation by mounting an init SQL script into the Postgres container so the schema is ready before Hibernate ORM starts.
Sort: