I have a maven project which has some Selenium based integration tests to run in a package called sit. I have configured the failsafe plugin to include test files in the package eg. <include>sit/**/*Test.java</include>
.
I am trying to run mvn clean install
and when it launches the tests I noticed it hasn't actually run the maven-war-plugin i.e. not packaged it into a war prior to running the tests. If however I run mvn clean install -Dmaven.test.skip=true
then it does successfully package the war. (I also have the cargo plugin configured to deploy the war which is how I noticed there was an issue as it fails to deploy a non existing war)
The structure of my pom is similar to the below
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>a</groupId>
<artifactId>a</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>sit/**/*Test.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Any ideas why it doesn't run the war plugin without setting -Dmaven.test.skip=true
?
It does in both scenarios create the class files
Ok it seems the issue was maven-surefire was trying to run the integration tests as unit tests, so we have to explicitly exclude the integration tests from surefires unit tests
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
...
<configuration>
<excludes>
<exclude>sit/**/*Test.java</exclude>
</excludes>
</configuration>
</plugin>