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

+Arquillian will be represented at JavaOne Tokyo 2012 by +Ray Ploski and +Takayuki Konishi Rapid ...
Feb 22, 2012 10:55 AM
+Arquillian will be represented at JavaOne Tokyo 2012 by +Ray Ploski and +Takayuki KonishiRapid development of Java EE applications using Forge and Arquillianhttps://oj-events.jp/public/session/view/190Introduction to automated Java EE testing by testing incontainerhttps://oj-events.jp/public/session/view/201Must see! :)ホーム: JavaOne Tokyo 2012日本オラ…
JavaEE6 Lab with +Feb 21, 2012 7:04 PM
JavaEE6 Lab with +Arquillian at DEVOXX France, presented by +Antoine Sabot-Durand +Alexis Moussine-Pouchkine +Alexis HasslerAntoine Sabot-Durand originally shared this post:Concerning #devoxxfr so far my following talk where accepted :A University on #CDI #SeamSocial and #Java_Social and #Weld_OSGI that I'll do with +Mathieu ANCELIN …
Arquillian Live Hackfest #devconf
Feb 17, 2012 9:14 AM
Arquillian Live Hackfest #devconfLukáš Fryč originally shared this post:We would like to invite you to brain-storm over the future of testing!Arquillians are invading Brno these days and by recent measurements,we have identified a massive talent concentration in testing space.It doesn't matter what you know about Arquillian,you can join us and shar…
View more latest project blog entries

Latest Community Blogs and Articles

Java Spotlight #51: Live at Java One - Java Platform Timelines & Duke Choice Award Winners
This live recording at JavaOne 2011 San Francisco features Java Platform timelines presented at Java One 2011 San Francisco in the news segment and interviews with the 2011 Duke Choice Award Winners for the feature interview. Tags: podcast javaone arquillian award dukeschoice
Migration to Arquillian
How the RichFaces functional tests suites were migrated to Arquillian framework Tags: arquillian ajocado selenium drone migration
Next Generation Application Development: Java Enterprise Testing
Seit der Einführung von Java EE ist das Testen von Enterprise-Applikationen schwieriger geworden. Ein wesentlicher Grund liegt darin, dass Komponenten in einer Enterprise-Architektur selten in sich abgeschlossen sind, sondern mit vielen anderen Komponenten des Systems zusammenspielen. Java-EE-6-Container wie Glassfish v3 oder JBoss AS6 sind zum Beispiel für das Dependency Management und die Persistenz zur Datenbank (JPA 2.0) verantwortlich. Das Zusammenspiel der Geschäftslogik mit anderen Komponenten wird in Enterprise-Applikationen immer wichtiger, ähnlich wie die Implementierung der Geschäftslogik selbst. Vor allem deklarative Beschreibungen, wie Dependency Injection und Transaktionskontrollen, müssen daraufhin getestet werden, ob sie die gewünschten Aufgaben erfüllen. Unit-Tests und Mock-Tests können nur einen begrenzten Teil dieser Überprüfungen übernehmen. Integrationstests spielen daher eine immer wichtigere Rolle. Tags: arquillian testing article german
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 #90 (stable)

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