JBoss Community Archive (Read Only)

Arquillian Old

Setting up Arquillian in a Maven project

The quickest way to get started with Arquillian is to add it to an existing Maven 2 project. Regardless of whether you plan to use Maven as your project build, we recommend that you take your first steps with Arquillian this way so as to get to your first green bar with the least amount of distraction.

The first thing you should do is define a Maven property for the version of Arquillian you are going to use. This way, you only have to maintain the version in one place and can reference it using the Maven variable syntax everywhere else in your build file.

<properties>
   <arquillian.version>1.0.0.CR1</arquillian.version>
</properties>

Make sure you have the correct APIs available for your test. In this test we are going to use CDI:

<dependency>
   <groupId>javax.enterprise</groupId>
   <artifactId>cdi-api</artifactId>
   <version>1.0-SP4</version>
</dependency>

Next, you'll need to decide whether you are going to write tests in JUnit 4.x or TestNG 5.x. Once you make that decision (use TestNG if you're not sure), you'll need to add either the JUnit or TestNG library to your test build path as well as the corresponding Arquillian library.

If you plan to use JUnit 4, begin by adding the following two test-scoped dependencies to the <dependencies> section of your pom.xml.

<dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.8.2</version>
   <scope>test</scope>
</dependency>

<dependency>
   <groupId>org.jboss.arquillian.junit</groupId>
   <artifactId>arquillian-junit-container</artifactId>
   <version>${arquillian.version}</version>
   <scope>test</scope>
</dependency>

If you plan to use TestNG, then add these two test-scoped dependencies instead:

<dependency>
   <groupId>org.testng</groupId>
   <artifactId>testng</artifactId>
   <version>5.14.9</version>
   <scope>test</scope>
</dependency>

<dependency>
   <groupId>org.jboss.arquillian.testng</groupId>
   <artifactId>arquillian-testng-container</artifactId>
   <version>${arquillian.version}</version>
   <scope>test</scope>
</dependency>

That covers the libraries you need to write your first Arquillian test case. We'll revisit the pom.xml file in a moment to add the library you need to execute the test.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-10 12:18:47 UTC, last content change 2011-07-25 13:40:35 UTC.