Search code examples
javajunittestcontainers

Why does my Testcontainers test hang till timeout on "Waiting for database connection to become available at"?


When constructing a JUnit test using Testcontainers my test hangs until timeout after the message "Waiting for database connection to become available at" and the container logs, then helpfully shown, do not yield any error. I can even connect to the running docker container with my favourite JDBC-query-tool.

Currently I'm using the MySQL container.


Solution

  • This is because I did not include the MySQL JDBC driver in my classpath. The Testcontainers does not log the fact that the 'SELECT 1', it suggests it's doing, is going wrong because of the missing driver. Normally it should fail with some timeout first until the container is up-and-running. But now it fails due to the missing driver and it somehow does not make a distinction.