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:
- I want to have Arquillian integration tests which test the code contained by the
webmodule. - These tests will be contained in a separate
web-itmodule. - Since the
webmodule depends on thedomainmodule, theweb-itintegration tests will also need to have the code from thedomainmodule on the classpath. - Both
domainandwebhave dependencies on some third party libraries, such asorg.apache.commons:commons-lang3which will also be needed on the test classpath. - 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:
Make
web-itdepend onwebby adding the following toweb-it/pom.xmlas 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
webon the test classpathMake
web-itdepend on the classes ofwebby configuring the war plugin ofwebto produce an attached classes jar. Inweb/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
webon the test classpath, but none of the transitive dependencies (such ascommons-lang3).
I've also considered, but not yet tried:
- 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.
- 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.