I want the maven to deploy war before running the jUnit tests.
I have added the failsafe plugin and a configuration but the deploy is still done after the tests.
Are the tests not run by the failsafe plugin?
<build>
<finalName>testWar</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.16</version>
<configuration>
<systemPropertyVariables>
<wildfly.remote.port>10090</wildfly.remote.port>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.2.1.Final</version>
<configuration>
<hostname>host</hostname>
<port>10090</port>
<username>user</username>
<password>pw</password>
</configuration>
<executions>
<execution>
<id>wildfly-run</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
The behaviour you report suggests that your tests are being run in the test
phase instead of the integration-test
phase. This is because by default both the Maven Surefire and Maven Failsafe plugins use class name conventions to differentiate between the two types of tests, as described below:
The Maven Surefire Plugin runs unit tests in the test
phase. By default it selects tests to execute based on the class name of the test, as described in Maven Surefire Plugin | Inclusions and Exclusions of Tests:
The Maven Failsafe Plugin runs integration tests tests in the integration-test
phase. By default it also selects tests to execute based on the class name of the test, as described in [Maven Failsafe Plugin | Inclusions and Exclusions of Tests](https://maven.apache.org/surefire/maven-failsafe-plugin/examples/inclusion-exclusion.html:
Therefore you probably just need to rename your integration test classes to conform with one of the three conventions shown above.