I'm trying to create Arquillian unit test using http://arquillian.org/arquillian-cube extension where you can set a breakpoint on the server side.
I've created a project which executes a simple test successfully (all details are here):
https://github.com/scetix/arquillian-cube-wildfly-quickstart
Is there any way of automatically attaching IntelliJ IDEA debugger to Wildfly running in Docker container when the test starts?
Automatically, I don't think so. In case of the Docker example, from the point of view of the IDE that is considered a remote server.
So what you need to do is first of all start Wildfly with debug enabled (http://tools.jboss.org/blog/2015-03-17-debugging-an-externally-launched-wildfly.html) and expose the debugger port correctly (https://github.com/scetix/arquillian-cube-wildfly-quickstart/blob/master/src/test/resources/Dockerfile#L12). Put these lines into you Dockerfile
:
# Expose JBoss/Wildfly management port
EXPOSE 9990
# Expose JBoss/Wildfly debug port
EXPOSE 8787
You also need to set the port binding for Docker Compose (https://github.com/scetix/arquillian-cube-wildfly-quickstart/blob/master/src/test/resources/docker-compose.yml#L5). Add port 8787 for the debugger to the YAML file (first number - 58787 here - may be any number you prefer):
ports:
- 58787:8787/tcp
And finally start IntelliJ as a remote debugger, setting the IP of the Docker host (localhost in case of native Docker, Docker Machine IP in case of Docker Machine).
You can see how to do this with IntelliJ: http://blog.trifork.com/2014/07/14/how-to-remotely-debug-application-running-on-tomcat-from-within-intellij-idea/. The example is for Tomcat; specify JBoss instead.