Search code examples
integration-testingscalatesttestcontainers

Test Container test cases do not run due to "Could not find a valid Docker environment", scalatest, os x, Docker Desktop


Trying to run integrations tests with Scalatest on my mac. Got the error:

java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration

The integration tests depend on a postgres instance in a container.

I don't understand. Docker Desktop is actually started since I can even execute SQL requests in a PG container and get responses.


Solution

  • In my scala project with scalatest, testcontainers and sbt, when using :

    "com.dimafeng" %% "testcontainers-scala-scalatest" % "0.40.12" % IntegrationTest,
    

    docker is not found. Whereas, when using :

    "com.dimafeng" %% "testcontainers-scala-scalatest" % "0.41.0" % IntegrationTest,
    

    docker is found and the integration tests do run.

    It would seem that testcontainers-scala-scalatest "0.40.12" is not compatible with "Docker Desktop 4.25.2 (129061)" (and probably a couple earlier versions…). Thankfully, version "0.41.0" is compatible with current Docker Desktop.