5

I have found bits and pieces of knowledge around the web, but haven't been able to put it together to solve this specific case. This answer seems a pretty good start, but it deals specifically with an EAR dependency.

My (simplified) maven project structure is as follows:

parent
 |__domain     (a jar)
 |__domain-it  (integration tests for the domain module)
 |__web        (a war; depends on domain)
 |__web-it     (integration tests for the web module)

I'm looking for a solution to the following:

  1. I want to have Arquillian integration tests which test the code contained by the web module.
  2. These tests will be contained in a separate web-it module.
  3. Since the web module depends on the domain module, the web-it integration tests will also need to have the code from the domain module on the classpath.
  4. Both domain and web have dependencies on some third party libraries, such as org.apache.commons:commons-lang3 which will also be needed on the test classpath.
  5. The tests need to run both via Maven on the command line and directly within Eclipse via junit.

I am running on Glassfish 3.1.2.

Any help would be appreciated. It's weird to me that there is no specific Arquillian documentation for this scenario, since I imagine it's a pretty common one. Perhaps I am missing something fundamental?

Here is some of what I have tried so far:

  1. Make web-it depend on web by adding the following to web-it/pom.xml as follows:

    <dependency>  
        <groupId>${project.groupId}</groupId>
        <artifactId>web</artifactId>
        <version>${project.version}</version>
        <scope>test</scope>
        <type>war</type>
    </dependency>
    

    But this won't include any classes from web on the test classpath

  2. Make web-it depend on the classes of web by configuring the war plugin of web to produce an attached classes jar. In web/pom.xml:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
            <attachClasses>true</attachClasses>
        </configuration>
    </plugin>
    

    In web-it/pom.xml:

    <dependency>  
        <groupId>${project.groupId}</groupId>
        <artifactId>web</artifactId>
        <version>${project.version}</version>
        <scope>test</scope>
        <classifier>classes</classifier>
    </dependency>
    

    This includes the classes from web on the test classpath, but none of the transitive dependencies (such as commons-lang3).

I've also considered, but not yet tried:

  1. Using the Maven Warpath plugin, as described in this answer. There seem to be some issues when this is used with m2e/eclipse though, and I want to be able to run my integration tests from eclipse.
  2. Using the MavenImporter ShrinkWrap Resolver somehow to just create an Arquillian deployment based on the project pom. I'm not sure how this will go running in eclipse (ie outside of maven), but it also means I need to effectively deploy the entire WAR, rather than just a subset of it - a feature of Arquillian that I like and would like to be able to preserve.
Community
  • 1
  • 1
Ryan Bennetts
  • 1,143
  • 2
  • 16
  • 29

0 Answers0