Main Content

Arquillian

Arquillian

Test in-container!
Arquillian is revolutionary platform that greatly simplifies integration testing for Java middleware. No more mocks. No more container lifecycle and deployment hassles. Just real tests!

The mission of the Arquillian project is to provide a powerful testing platform that handles all the plumbing of managing the container lifecycle, deployment and framework initialization so you can focus on writing your integration tests. Real tests.

In short...

Arquillian makes integration testing a breeze!

Arquillian minimizes the burden on you—the developer—by encapsulating your integration test in a lifecycle that performs the following steps:

  • Manages the lifecycle of the container (start/stop),
  • Bundles the test class with dependent classes and resources into a deployable archive,
  • Enriches the test class (e.g., resolving @Inject, @EJB and @Resource injections),
  • Deploys the archive to test (deploy/undeploy) and
  • Captures results and failures.

To avoid introducing unnecessary complexity into the developer’s build environment, Arquillian integrates seamlessly 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.

Prove it.

Sure thing. Consider an integration test for an EJB. How do you start the container? Deploy the EJB? Get the EJB reference? Run the test in an IDE? Use any EJB container?

Arquillian takes care of all that! Did you think it could be this easy?

import static org.junit.Assert.assertEquals;
import javax.ejb.EJB;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
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 ShrinkWrap.create(JavaArchive.class, "test.jar")
         .addClasses(GreetingManager.class, GreetingManagerBean.class);
   }

   @EJB
   private GreetingManager greetingManager;

   @Test
   public void shouldGreetUser() throws Exception {
      String name = "Earthlings";
      assertEquals("Hello, " + name, greetingManager.greet(name));
   }
}
 
The just the beginning of what's possible. See more examples...

Learn More

Explore the capabilities that Arquillian brings to your tests.

Test runners

We know you have your own preference when it comes to test frameworks. Arquillian provides test runners for the two most popular choices:

  • JUnit 4 (or better)
  • TestNG 5 (or better)

The integration is completely transparent, which means you can launch the tests and get results using available IDE, Ant and Maven test plugins without any add-ons.

Additional test runners, such as Spock and JBehave, are supported through extensions.

Test archives

One of the biggest challenges with testing is configuring the code to test. You may need to:

  • swap in mock objects to enable the code to function,
  • reconfigure the application to use a test database,
  • deal with classpath isolation issues or
  • run a build to assemble and deploy the application archive.

These steps are time consuming. ShrinkWrap to the rescue!

ShrinkWrap allows you to skip the build and instead define a deployment archive (jar, war, ear) declaratively in Java code. You define an archive inside your test case, termed a "micro deployment", and Arquillian deploys it to the container prior to executing the test case. Only those classes and resources in the archive are visible to the test case.

This strategy gives you tremendous control over the code you're testing and fast turnaround.

Test enrichment

Arquillian enriches the test class with services such as:

  • injection
  • contexts
  • interceptors

These services provide easy access to components under test and allows the test to abstract away plumbing, such as a transaction boundaries.

Here are some of the injection types that Arquillian supports in Java EE environments:

  • @Inject (supported in any CDI environment)
  • @Resource
  • @EJB
  • @PersistenceUnit / @PersistenceContext

Arquillian provides an SPI that allows you to introduce additional enrichment to this list.

Containers

The test class does not reference the container directly. That means you can run the same test case against various containers and you don't get locked into a proprietary test environment. It also means you can select the optimal container for development or easily test the compatibility of your application.

Arquillian recognizes three container interaction styles:

  • A remote container resides in a separate JVM from the test runner. Arquillian binds to the container to deploy the test archive and invokes tests via a remote protocol (e.g., Servlet).
  • A managed container is the same as a remote container, but its lifecycle (startup/shutdown) is also managed by Arquillian.
  • An embedded container resides in the same JVM and is mostly likely managed by Arquillian. No need to fiddle with Maven plugins!

A container is further classified by its capabilities:

  • Java EE application server (e.g., JBoss AS, GlassFish)
  • Servlet container (e.g., Tomcat, Jetty)
  • standalone bean container (e.g., OpenEJB, Weld SE)
  • OSGi container

Arquillian provides an SPI that allows you to introduce any additional container to this list.

Run modes

Each Arquillian test can control its own run mode, of which there are two:

  • in-container (in-process invocation)
  • client (through a remote client)

In the first mode, Arquillian puts the test class inside the container alongside the components under test. Then, the test directly invokes the methods of the component instance that Arquillian injects.

Arquillian also supports deploying the application code separately to allow the test to act as a remote client to the deployed archive.

You can also mix and match these modes to cover a myriad of testing scenarios.

Latest Project Blog Entries

The Arquillian Ajocado project is in need of clothing We need a fresh look to tackle the bright f...
Feb 8, 2012 6:58 AM
The Arquillian Ajocado project is in need of clothingWe need a fresh look to tackle the bright future ahead. Something that will make us(and you!) memorable for years to come. Show of your design skills and give us a hand!...fame and fortune awaits you...Ajocado project logo | Arquillian | JBoss Community
Arquillian + Arquillian Drone
Feb 7, 2012 12:05 PM
Arquillian + Arquillian DronePavol Pitoňák originally shared this post:How we migrated #RichFaces test suite to #Arquillian.Learn and share: Migration to Arquillian - doneOur former functional test suite was written as Selenium tests, more precisely we used our homemade framework (RichfFaces Selenium) in top of Selenium 1, from which Arquillian Ajo…
Heading over to FOSDEM 2012 this weekend in Brussels, Belgium? Don't miss +Koen Aers Saturday tal...
Jan 31, 2012 7:19 AM
Heading over to FOSDEM 2012 this weekend in Brussels, Belgium? Don't miss +Koen Aers Saturday talk on JBoss Forge and +Arquillian: Two Missing Links in Enterprise Java Development!Time 3:00pm–3:55pm WETDate 4th February 2012JBoss Forge / Arquillian: Two Missing Links in Enterprise Java Development at FOSDEM 2012 | LanyrdOne common complaint you hea…
View more latest project blog entries

Latest Community Blogs and Articles

Building and testing ADF applications with Maven, JSFUnit, Arquillian and Embedded GlassFish
Some time ago I have been playing with Java Server Faces 2.0 (e.g. JSF 2) and JSFUnit in combination with Arquillian and Embedded Glassfish as a Proof Of Concept for unit testing JSF applications. As our applications are being developped with the Oracle ADF framework, I was wondering if it would be possible to do the same with ADF based applications. Tags: arquillian jsfunt adf glassfish embedded examples poc
JBoss 7 und Arquillian
Das Testen von J2EE war ja immer pain in the ass, dass kam JEE mit EJB 3, alles war ein POJO und siehe da: man brauchte keinen Application-Server mehr, um seine Logik zu testen (in den meisten Fällen zumindest). Dann kam Arquillian, weil man sah, dass man ggf. doch mal einen Application-Server benötigt für sinnvolle Tests. Tags: arquillian maven integration jbossas7 article german
Arquillian with NetBeans, GlassFish embedded, JPA and a MySQL Datasource
This is an, let's call it accidental post. I was looking into transactional CDI observers and playing around with GlassFish embedded to run some integration tests against it. But surprisingly this did not work too well and I am still figuring out, where exactly the problems are while using the plain embedded GlassFish for that. In the meantime I switched to Arquillian. Tags: arquillian integration cdi jpa glassfish tutorial
View more latest community blogs and articles

About the Project

Project Team

Arquillian is led by Aslak Knutsen.

Additional core team members include:

But the real heros are large group of community contributors, particularly the Arquillian Nobles.

Project Status

The Arquillian project uses the JBoss issue tracker and project management tool to organize and prioritize tasks.

Arquillian Issue Tracker | Open Issues | Roadmap

JBoss Testing

Arquillian is part of the JBoss Testing initiative, which is an effort to unify the testing-related projects to provide a comprehensive testing tool set for application developers.

The projects involved so far are:

The initiative brings together developers in the JBoss Community who are passionate about testing. You can find us on the #jbosstesting channel on Freenode IRC.

History

Arquillian originated as the JBoss Test Harness - created by Pete Muir as the foundation of the JSR-299 (CDI) and JSR-303 (Bean Validation TCKs). This work established the guiding principles of Arquillain - that the tests should be reusable in any container (because executing tests in a full Java EE container is expensive), that it was essential tests could be easily run easily from an IDE (to make debugging easy), and that the framework needed to build on existing test harnesses to allow reuse of existing tools.

The JBoss Test Harness prototyped a solution that provided:

  1. Declarative, annotation driven assembly of archives - needed to allow easy execution from the IDE, without having to call out to a slow and cumbersome build script. In Arquillian this was replaced by ShrinkWrap, a fluent Java API for assembling archives such as JARs, WARs and EARs in Arquillian.
  2. A Java Adapter API which could start/stop a container and deploy a test. This was needed to allow running inside an IDE, and also allow a test to be reused in multiple environments
  3. Easy switching between incontainer and standalone mode. Arquillian demoted this concept, and instead treats incontainer and standalone tests as different types of containers
  4. Packaging of the test case alongside the archive you deploy and delegating to TestNG to perform test execution, both in and out of the container
  5. A pluggable test executor, allowing the framework to select incontainer execution or standalone execution for the same test

It quickly became obvious that this was something that could be really useful to other people outside of the CDI TCK and Bean Validation TCKs. As Pete had hacked the JBoss Test Harness together in 3 weeks, it was obviously better to take just the ideas and start afresh. At the time, work on Java EE 6 was reaching a crucial point, so this project was put on the backburner until late-2009, when Aslak popped up and quickly picked up the key ideas creating a clean, pluggable architecture, added JUnit support and test enrichment. Obviously we had to hire him!

Since then, support has been added for additional containers, more sophisticated test enrichment and other test framework integrations. Arquillian was put to use immediately as the foundation of the test suites in the Seam 3 modules and examples.

The artwork for the project was created by Cheyenne Weaver over many long months of creative deliberation with the project team.

The project name may or may not be related to the alien species from a popular movie about protecting the Earth from alien scum. We just want to protect you from infrastructure scum in your integration tests.

Arquillian-Core all builds

Arquillian-Core #89 (stable)

Recent Commits

Aslak Knutsen ARQ-670 Context-Root should not include Archive extension
Feb 8, 2012 12:49 PM
Marek Schmidt ARQ-717 add partition property
Jan 20, 2012 4:50 AM
Alexis Hassler ARQ-715 Add a getter for ProtocolMetaData.contexts
Jan 2, 2012 10:11 AM
Aslak Knutsen ARQ-703 prepare for next development iteration
Dec 15, 2011 6:47 PM
Aslak Knutsen ARQ-703 prepare release 1.0.0.CR7
Dec 15, 2011 6:47 PM
View more recent commits

Testimonials

All in all Arquillian is a really great integration testing tool with full of potential. It's just great that the JBoss guys are aiming to provide support for almost all widely used application servers and web containers.

If you are writing an application for the Java EE 6 stack while not using Arquillian is a serious mistake!
Bartosz Majsak
This reminds me of the old Cactus project back in the day, but done much, much better.
Laird Nelson

Arquillian logo

Logos | Swag | Desktop wallpaper