Skip to end of metadata
Go to start of metadata

Each Arquillian test is associated with at least one deployment. The deployment is configured using a static method annotated with @Deployment that returns a ShrinkWrap archive. Here's an example:

Why is a deployment necessary?

If we want to be able to test inside the container, we need some way to get the code into the container. A container typically accepts some form of deployment. In most Java-based containers, these deployments are some sort of Java archive (jar).

ShrinkWrap provides a way to define a deployment archive (e.g., jar, war, ear) in Java using a fluent API. You use this API to create an deployment that's associated with the test case, which we call a "micro deployment". Arquillian can then use this object to stream the contents to the server in the most efficient way available.

The deployment archive is more than just a means to an end (getting code inside the container). There are several critical benefits to defining a deployment:

  1. It allows you to isolate the classpath of the test – only those classes and resources inside the deployment are visible to the test
  2. You can emulate or replicate a deployment scenario, which often triggers behavior (e.g., framework activation) that you cannot otherwise test
  3. We can skip the build. Since the archive is assembled in Java, we're able to leverage the incremental compilation provided by IDEs

In summary, the strategy of using ShrinkWrap-based deployments gives you tremendous control over the code you're testing and quicker turnaround.

Arquillian provides the SPI org.jboss.arquillian.spi.client.deployment.DeploymentScenarioGenerator to allow an alternate means of defining a deployment, including foregoing the use of a deployment altogether.
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Oct 08, 2014

    How can I avoid isolation of classpath of the test? How can I inject the necessary resources into the test class in case when I have already deployed remote server with all resources and don't need any deployment. Is it possible?

  2. Dec 29, 2015

    Good Day,

    when I am executing below api code on linux, I am getting error as org.jboss.shrinkwrap.descriptor.api.DescriptorImportException: Could not import XML from stream

    Descriptors.importAs(ApplicationDescriptor.class).fromStream(applicationXmlNodeInputStream);

    Please assist me. This code is working fine on window's environment.

    Cheers,

    Raghu