Java Reference
In-Depth Information
Writing your first Arquillian test
Once the configuration is complete, we will finally code our test. So, create a Java class
named TicketTest under the package
com.packtpub.wflydevelopment.chapter13.test . The first thing that you
will add to this class is the following annotation that tells JUnit to use Arquillian as the test
public class TicketServiceTest {
Arquillian then looks for a static method with the @Deployment annotation; it creates a
micro deployment including all the specified classes and resources (instead of deploying
the whole application), allowing to test only part of the system:
public static Archive<?> createTestArchive() {
return ShrinkWrap.create(WebArchive.class)
The fluent API provided by the ShrinkWrap project ( )
makes this technique possible using the create method, which accepts the type of de-
ployment unit ( WebArchive ) as the argument and all the resources are included in this
archive. In our case, instead of including all the single classes, we use the addPackage
utility method that adds all the classes that are contained in a class package (for example,
by adding the SeatType.class.getPackage() method, we will include all the
classes that are in the same package as the SeatType class). Our project uses the JPA, so
we also add persistence configuration; here, we specify a path to the .xml file, so we can
point, for example, to some other test configuration using some other non-production data-
Search WWH ::

Custom Search