I have a multi-module Maven project and I'm trying to setup integration testing tooling with the failsafe plugin.
I added the following to the project's parent pom.xml:
<profiles>
<profile>
<id>failsafe</id>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
I also added that exact same snippet to the child module's pom.xml where the initial tests were added along with this snippet:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
</plugins>
</build>
Here is the directory structure of the module where the initial integration test has been added:
parent
-aws-service-utils
--src
---main
----java
-----com
------lorem
-------ipsum
--------S3
---------S3.java (dummy class)
---test (in same directory as main)
----java
-----com
------lorem
-------ipsum
--------dolor
---------tests
----------S3IT.java (test class for dummy class)
Here's what S3.java
looks like, excluding the imported packages:
public class S3 {
public int confirmAdd() {
int sum = 2 + 2;
return sum;
}
}
Here's what S3IT.java
looks like, again excluding imported packages:
public class S3IT {
@Test
public void confirmAdd() {
int sum = 2+2;
assertTrue(sum == 4);
}
}
I run mvn verify -Pfailsafe
followed by mvn failsafe:integration-test
and get no test output for all of the other classes, as expected. Then the following comes up for the aws-service-utils
module:
So it appears to be recognizing the integration test class S3IT.java but not the test inside. I went through the proposed solutions in a similar Stack Overflow post and none of them worked. My primary resource for setting up integration tests with Maven can be found here.