2 Replies Latest reply on Nov 25, 2013 2:39 PM by Martin Ahrer

    Need some explanation of which dependencies need to be added to a deployment

    Martin Ahrer Newbie

      I have recently started looking at Arquillian an like the many abstractions for various containers. My past attempts for full blown integration testing mostly involved some clumsy solutions based on various Maven plugins.

      So I have been able to get a simple REST service running with embedded Tomcat 7 and running a test against that REST service. Here is how my test roughly looks:



      public class TaskTest {


          private URL contextPath;

          @Deployment(testable = false)

          @OverProtocol("Servlet 3.0")

          public static WebArchive create() {

              return ShrinkWrap










          public void test() {









      This is based on Spring framework libraries that are set up in my IDEA (using Gradle). So when starting up my test in IDEA or Gradle, Arquillian nicely boots Tomcat, starts my web application. But nowhere I have ever set up ShrinkWrap to include any libraries (JARs). I only add the web initialiser (Servlet 3.0) and this makes it happen magically and the container has a class path fully setup.


      However, reading though all the Arquillian documentation, my expectation was that I have to add every single class file, package, web resource, JAR file, etc. that needs to be deployed to the container. Just running my sample application kind of ruined that impression. So I must have missed something important. Where can I find an explanation, how the container class path will be set up effectively. What items really need to be deployed explicitly by ShrinkWrap?



        • 1. Re: Need some explanation of which dependencies need to be added to a deployment
          Karel Piwko Master

          Hey Martin,


          there are basically two different things:


          Microdeployments define only what is really needed to run the test. The point is they are small and thus quickly deployable. You can think of testing a EJB, for instance, you need only to deploy interface and its implementation. Microdeployments are basically core for unit testing. Microdeployments are usually tested in container = the test runs in the JVM of application server inside of the application, which is default behavior.


          Full deployments define the application as you would deploy it. There are used mainly for functional testing, where you need to package your application the same way as you would do manually. Full deployments are usually tested in as client mode, defined by @Deployment(testable=false) or by @RunAsClient annotation. Client mode means that server with app is different JVM than test itself. So REST and Selenium are the most logical testing means here.


          So, the point is to figure out what you exactly need. There are the bits you should take in mind:

          • if the classes you want to deploy depend on libraries, you need to add those libraries into deployment unless they are provided by application server. That's the reason why Servlet 3.0 works fine and Spring is not. See ShrinkWrap Resolvers how to do that https://github.com/shrinkwrap/resolver/blob/master/README.asciidoc
          • if you want to test UI, you likely need to deploy content of src/main/webapp. You can use ShrinkWrap Resolver MavenImporter, ShrinkWrap ZipImporter or ExplodedImporter or an utility that recursively traverse that directory.
          • If you are running in Server, make sure that you deploy all the classes referenced by test class as well. For instance Apache Commons or such. They won't be available on server after deployment. (Note: Arquillian autoadds testing - junit, hamcrest, etc)





          • 2. Re: Need some explanation of which dependencies need to be added to a deployment
            Martin Ahrer Newbie

            Hi Karel,


            thanks for your explanation. But I fear I have not expressed my problem clear enough. My server side implementation consists of about 5 classes that make up my REST service (+ a ton of 3rd party libraries which are setup as dependencies in my IDE/gradle build).


            However, for my test I didn't add any of these classes nor did I add any of the 3rd-party libraries (as you see in my test code above) to the deployment. I only added the Servlet 3.0 Initializer but still when invoking the test (in IDE or from gradle command line) the test goes green.


            I'd expect ClassNotFoundExceptions etc. as I haven't really done my micro deployment. But in fact the REST service implementation finds all dependencies (classes+libraries) in its classpath.