In Java EE 6 Testing Part I I briefly introduced the EJB 3.1 Embeddable API using Glassfish embedded container to demonstrate how to start the container, lookup a bean in the project classpath and run a very simple integration test.
The source code used for this post is available on GitHub under the folder
Arquillian brings test execution to the target runtime, alleviating the burden on the developer of managing the runtime from within the test or project build. To invert this control, Arquillian wraps a lifecycle around test execution that does the following:
- Manages the lifecycle of one or more containers
- Bundles the test case, dependent classes and resources as ShrinkWrap archives
- Deploys the archives to the containers
- Enriches the test case with dependency injection and other declarative services
- Executes the tests inside (or against) the containers
- Returns the results to the test runner for reporting
ShrinkWrap, a central component of Arquillian, provides a simple mechanism to assemble archives like JARs, WARs, and EARs with a friendly, fluent API.
One of the major benefits of using Arquillian is that you run the tests in a remote container (i.e. application server). That means you’ll be testing the real deal. No mocks. Not even embedded runtimes!
The following topics will be covered on this post:
- Configure the Arquillian infrastructure in a Maven-based Java project
- Inject EJBs and Managed Beans (CDI) directly in test instances
- Test Java Persistence API (JPA) layer
- Run Arquillian in client mode
- Run and debug Arquillian tests inside your IDE