Skip to content

SYSTEM

Maven Failsafe Plugin

Maven Failsafe is the Apache Maven test runner designed for integration tests. It attaches to the integration-test and verify phases and, unlike Surefire, does not fail the build immediately on a failing test — it defers failure to verify, letting post-test cleanup (shutdown hooks, post-integration-test goals) run first. This matters when tests share expensive resources like Docker containers that need to tear down cleanly.

Default include patterns target IT naming conventions:

  • **/IT*.java
  • **/*IT.java
  • **/*ITCase.java

In practice, projects override this to use *IntegrationTest (Zalando ZMS convention) or similar.

Relevance to Testcontainers ingest

Zalando ZMS pairs Failsafe with Surefire: Surefire owns *Test in the test phase; Failsafe owns *IntegrationTest in the integration-test phase. A Maven profile (with-integration-tests) gates Failsafe — mvn test runs only unit tests, mvn verify -P with-integration-tests runs both. See patterns/failsafe-integration-test-separation.

The deferred-failure semantics pair naturally with Testcontainers-backed ITs: even if tests fail, Failsafe gives Testcontainers' shutdown hooks a chance to stop containers before the build aborts.

Seen in

  • — Zalando ZMS's canonical pom configuration for Failsafe: <include>**/*IntegrationTest.java</include> inside a with-integration-tests profile.
Last updated · 542 distilled / 1,571 read