Arquillian

 

Test in-container!

 

Arquillian provides a easy mechanism to test your application code inside a remote or embedded container or by interacting as a client of the container.

 

Mission Statement

 

The mission of the Arquillian project is to provide a simple test harness that developers can use to produce a broad range of integration tests for their Java applications (most likely enterprise applications). A test case may be executed within the container, deployed alongside the code under test, or by coordinating with the container, acting as a client to the deployed code.

 

Arquillian defines two styles of container, remote and embedded. A remote container resides in a separate JVM from the test runner. Its lifecycle may be managed by Arquillian, or Arquillian may bind to a container that is already started. An embedded container resides in the same JVM and is mostly likely managed by Arquillian. Containers can be further classified by their capabilities. Examples include a fully compliant Java EE application server (e.g., GlassFish, JBoss AS, Embedded GlassFish), a Servlet container (e.g., Tomcat, Jetty) and a bean container (e.g., Weld SE). Arquillian ensures that the container used for testing is pluggable, so the developer is not locked into a proprietary testing environment.

 

Arquillian seeks to minimize the burden on the developer to carry out integration testing by handling all aspects of test execution, including:

 

  • managing the lifecycle of the container (start/stop),
  • bundling the test class with dependent classes and resources into a deployable archive,
  • enhancing the test class (e.g., resolving @Inject, @EJB and @Resource injections),
  • deploying the archive to test (deploy/undeploy) and
  • capturing results and failures.

 

To avoid introducing unnecessary complexity into the developer's build environment, Arquillian integrates transparently with familiar testing frameworks (e.g., JUnit 4, TestNG 5), allowing tests to be launched using existing IDE, Ant and Maven test plugins without any add-ons.

 

Arquillian makes integration testing a breeze.

Project Information
Anonymous SCMhttp://anonsvn.jboss.org/repos/common/arquillian/trunk
Committer SCMhttps://svn.jboss.org/repos/common/arquillian/trunk
Issue Trackinghttps://jira.jboss.org/jira/browse/ARQ
Reference Guidehttp://docs.jboss.org/arquillian/reference/latest/en-US/html_single/
Demo documentation

Arquillian - Demo

User ForumsArquillian Space
Development ForumsArquillian Development Space
FAQ

Arquillian - FAQ

External Articleshttp://www.diigo.com/user/jbosstesting/arquillian
Project LeadAslak Knutsen
Contributors

Pete Muir, Dan Allen, Steven Boscarine, Andrew Rubinger

IRC#jbosstesting on irc.freenode.net


Modules
Module Name
Maven2 ID
Status
apiorg.jboss.arquillian:arquillian-apiDevelopment In Use
buildorg.jboss.arquillian:arquillian-buildDevelopment In Use
impl-baseorg.jboss.arquillian:arquillian-impl-baseDevelopment In Use
spiorg.jboss.arquillian:arquillian-spiDevelopment In Use
packager-javaeeorg.jboss.arquillian.packager:arquillian-packager-javaeeDevelopment In Use
packager-applicationarchiveorg.jboss.arquillian.packager:arquillian-packager-applicationarchiveDevelopment In Use
testenricher-ejborg.jboss.arquillian.testenricher:arquillian-testenricher-ejbDevelopment In Use
testenricher-resourceorg.jboss.arquillian.testenricher:arquillian-testenricher-resourceDevelopment In Use
testenricher-cdiorg.jboss.arquillian.testenricher:arquillian-testenricher-cdiDevelopment In Use
protocol-servletorg.jboss.arquillian.protocol:arquillian-protocol-servletDevelopment In Use
protocol-localorg.jboss.arquillian.protocol:arquillian-protocol-localDevelopment In Use
jbossas-embedded-60org.jboss.arquillian.container:arquillian-jbossas-embedded-60

Development In Use

jbossas-remote-51org.jboss.arquillian.contianer:arquillian-jboss-remote-51

Development In Use

jbossas-remote-60org.jboss.arquillian.container:arquillian-jboss-remote-60

Development In Use

weld-embeddedorg.jboss.arquillian.container:arquillian-weld-embeddedDevelopment In Use
glassfish-embedded-30org.jboss.arquillian.container:arquillian-glassfish-embedded-30Development In Use
openejborg.jboss.arquillian.container:arquillian-openejbDevelopment In Use
junitorg.jboss.arquillian:arquillian-junitDevelopment In Use
testngorg.jboss.arquillian:arquillian-testng

Development In Use

example-junitorg.jboss.arquillian.example:arquillian-example-junitDevelopment In Use
example-testngorg.jboss.arquillian.example:arquillian-example-testngDevelopment In Use
example-domainorg.jboss.arquillian.example:arquillian-example-domainDevelopment In Use

 

Release Plan
0.1.xRetiredPrototyping and Development Series
1.0.0.AlphaXIn ProcessEarly-access Release Series used primarily for testing integration and gathering community input
1.0.0.BetaXShort-termCandidate for Frozen APIs, major features are complete
1.0.0.CRXShort-termRelease Candidates; APIs stable except for bug fixes
1.0.0.FinalFuturePromoted from re-tag of a release candidate; Stable
1.0.x.FinalFutureIncremental Patch Releases; no API changes, backwards-compatible
1.x.y.FinalUnscheduledNew feature; backwards-compatibility preserved
2.0.0.AlphaXUnscheduledOverhaul, refactoring.  Features may be added/dropped, API contract disappears

 

 

Sample Code


Test a EJB in container using JUnit

package com.acme.ejb;

import javax.ejb.EJB;

import junit.framework.Assert;

import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archives;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class GreetingManagerTest
{
   @Deployment
   public static JavaArchive createDeployment() {
      return Archives.create("test.jar", JavaArchive.class)
               .addClasses(
                     GreetingManager.class,
                     GreetingManagerBean.class);
   }
   
   @EJB
   private GreetingManager greetingManager;
   
   @Test
   public void shouldGreetUser() throws Exception {
      
      String userName = "Devoxx";
      
      Assert.assertEquals(
            "Hello " + userName,
            greetingManager.greet(userName));
   }
}

 

Maven Dependencies

   <dependencies>

      <dependency>
         <groupId>org.jboss.arquillian</groupId>
         <artifactId>arquillian-junit</artifactId>
         <version>${version.org.jboss.arquillian_arquillian}</version>
      </dependency>
      <dependency>
         <groupId>org.jboss.arquillian.container</groupId>
         <artifactId>arquillian-jbossas-remote-60</artifactId>
         <version>${version.org.jboss.arquillian_arquillian}</version>
      </dependency>

   </dependencies>
Related

 

Further reading