Run gradle test tasks in docker from IntelliJ IDEA

Viewed 806

I'm working on a project that has functional tests that require a specific environment to run.

Some dependencies like a database are bootstrapped when running tests. Unfortunately this is not possible for all dependencies.

For the production version of the application a docker image is built that sets up the environment.

Is it possible to use e.g. IntelliJ's run targets to also run the functional tests within this docker environment? Trying to run it using the mostly default settings (see screenshot below) results in Connection refused.

docker run target

1 Answers

Interestingly, I don't even have the "Run on" option despite having the Docker plugin installed (Edit: Turns out the "Run on" option is only available in the Ultimate Edition of IntelliJ). So I was looking into an alternative way: Instead of configuring a Gradle task to run on Docker, you can create a Docker run configuration to execute a Gradle task like so:

enter image description here

Related