Creating a project with Arquillian JUnit support

Click Create New Project on the Welcome screen, or select File | New | Project.

The New Project wizard opens.

In the left-hand pane, select Java Enterprise.

If the JDK that you want to use is already defined in IntelliJ IDEA, select that JDK from the Project SDK list. Otherwise, click New, select JDK, and select the JDK installation folder in the dialog that opens.

If GlassFish is not defined in IntelliJ IDEA yet, click New to the right of the Application Server field and select Glassfish Server.

The initial content of the test class is defined by the corresponding template. You can edit that template on the Code tab of the File and Code Templates page in the Settings / Preferences dialog (Ctrl+Alt+S| Editor | File and Code Templates).

In the Download Library From Maven Repository dialog, type arquillian-glassfish-managed-3.1 and click . Then select org.jboss.arquillian.container:arquillian-glassfish-managed-3.1:1.0.0.CR4 from the list.

Select the Download to checkbox and click OK.

At this step, your Arquillian Containers dialog should look something like this:

Use your actual path to the GlassFish Server installation folder in place of C:\GlassFish\glassfish4.

Running the test in a managed container

To the right of the run configuration selector, click .

The Run tool window opens and the test result is shown there.

Close the tool window ().

Modifying arquillian.xml

Sometimes, you need to deploy your test to a container that is already running. In such cases, you can just change the container configuration file a little and continue using the managed container adapter.

Add the following to arquillian.xml:

<propertyname="allowConnectingToRunningServer">true</property>

Running the test: deploying to a running server

Start GlassFish Server: select GlassFish and click .

When the server is started, you'll see something like this in the Run tool window.