This short tutorial describes how to debug Arquillian Test Cases using a development environment like Eclipse IDE.
The prerequisite is that you have gone through the basics of Arquillian– you can start from here: Arquillian tutorial
As you already know, Arquillian tests are launched as JUnit test but are executed on the application server environment. Therefore, in order to intercept breakpoints that you have set in Eclipse, you should at first enable remote socket debugging. This can be done by uncommenting the following line from standalone.conf.bat (Windows):
set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"
Unix users, on the other hand will uncomment the following line in standalone.conf:
Remote Profile Testing
If you want to debug your Arquillian Tests against a running JBoss AS instance, start by setting the Active Maven Profile as arq-jbossas-remote (or as you called it in your pom.xml).
Now start WildFly / EAP from Eclipse using the Debug Option, as shown by the following picture:
Now set your breakpoints and execute your application as JUnit Test (Run as->JUnit Test). The Debugger perspective will kick in and you will be able to debug your test.
Managed Profile Testing
If you plan to debug your test using a JBoss AS instance managed by Arquillian, you have to set the remote socket debugging options from within your arquillian.xml file as shown by the following example:
<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> <engine> <property name="deploymentExportPath">target/</property> </engine> <container qualifier="jboss" default="true"> <protocol type="jmx-as7"> <property name="executionType">REMOTE</property> </protocol> <configuration> <property name="jbossHome">C:\jboss\jboss-as-7.1.1.Final</property> <property name="javaVmArguments">-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=y</property> </configuration> </container> </arquillian>
Now, set the Maven profile to run against a managed Arquillian profile:
Now set your breakpoints and execute your application as JUnit Test (Run as->JUnit Test). That’s all! Happy debugging!