You can also do it directly. This will add both test classes and test resources to WEB-INF / classes:
<plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <phase>process-test-classes</phase> <configuration> <target> <copy todir="${basedir}/target/classes"> <fileset dir="${basedir}/target/test-classes" includes="**/*" /> </copy> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin>
I also recommend that you place it in a separate profile, such as "integration", and also override the package name in this profile so that it cannot confuse a normal war without validation tests and testing.
Full example with profile here . You can run mvn clean package to have war war-it-test.war without tests included, or you can run mvn clean package -Pintegration for war war-it-test-integration.war for war with included tests.
Ivan Sopov
source share