Maven Failsafe Integration Tests Not Running in CI - Bind the Goals
maven-failsafe-plugin runs integration tests (*IT) in the integration-test/verify phases. If its goals are not bound, or the job runs mvn test (which only runs Surefire unit tests), the ITs never execute.
What this error means
Integration tests named *IT are not executed; CI is green having run only unit tests. Or mvn integration-test runs them but their failures do not fail the build because verify was never called.
[INFO] --- maven-surefire-plugin:3.2.5:test ---
[INFO] Tests run: 12 (only unit tests)
# *IT classes never run because the job called 'mvn test', not 'mvn verify',
# and/or failsafe goals were not boundCommon causes
Failsafe goals not bound
Without <executions> binding integration-test and verify, the plugin does nothing during the lifecycle.
Job runs test instead of verify, or wrong naming
mvn test stops before integration-test. Failsafe also only includes *IT/IT* by default, so *Test-named ITs are skipped.
How to fix it
Bind the Failsafe goals and run verify
Declare both goals and have CI call verify so the assert step fails the build on IT failures.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.2.5</version>
<executions>
<execution>
<goals><goal>integration-test</goal><goal>verify</goal></goals>
</execution>
</executions>
</plugin>Run the right phase and name ITs correctly
- Invoke
mvn -B verify(nottest) in CI so integration-test and verify run. - Name integration tests
*ITor configure includes to match yours. - Confirm the
verifygoal is present so IT failures actually fail the build.
How to prevent it
- Bind Failsafe to integration-test/verify, name ITs
*IT, and always runmvn verifyin CI so integration failures are not silently passed.