Repaso
EspaƱol
Maven, Git & SDLCIntermediateVCS-09

What is the difference between Maven Surefire and Failsafe plugins?

Options

  1. They are the same plugin under two different names
  2. Surefire runs unit tests (*Test); Failsafe runs *IT (Correct option)
  3. Surefire builds Docker images for the application
  4. Failsafe only works on Windows machines and servers

Answer

Surefire runs unit tests in the test phase (*Test); Failsafe runs integration tests in integration-test/verify (*IT) so a failure does not leave resources half-cleaned

Why

Plugins do the real work in each Maven phase.

  • maven-surefire-plugin: runs unit tests during test (classes named *Test).
  • maven-failsafe-plugin: runs integration tests (classes named *IT) during integration-test, and checks results in verify. This separation lets Maven shut down external things (like a test server) before reporting failure.

This split keeps mvn test fast.

Remember

Surefire = unit tests. Failsafe = integration tests.

Key terms

Practice this question in Repaso