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
web
module. - These tests will be contained in a separate
web-it
module. - Since the
web
module depends on thedomain
module, theweb-it
integration tests will also need to have the code from thedomain
module on the classpath. - Both
domain
andweb
have dependencies on some third party libraries, such asorg.apache.commons:commons-lang3
which 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-it
depend onweb
by adding the following toweb-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 classpathMake
web-it
depend on the classes ofweb
by configuring the war plugin ofweb
to 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
web
on 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.