Maven - Test


Test is a phase that:

  • execute the tests.
  • test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed

The Maven lifecycle has four phases for running integration tests:

  • pre-integration-test for setting up the integration test environment.
  • integration-test for running the integration tests.
  • post-integration-test for tearing down the integration test environment.
  • verify for checking the results of the integration tests.




When running integration tests, you should invoke Maven with the (shorter to type too)

mvn verify

rather than trying to invoke the integration-test phase directly, as otherwise the post-integration-test phase will not be executed.

Without test

mvn install -DskipTests

See Maven - D Argument


To run the test you use a plugin:

  • With the surefire plugin executes the test, when you have a test failure, the build will stop at the integration-test phase and your integration test environment will not have been torn down correctly.
  • The Failsafe Plugin. When it fails, it does so in a safe way. It is used during the integration-test and verify phases of the build lifecycle to execute the integration tests of an application. The Failsafe Plugin will not fail the build during the integration-test phase, thus enabling the post-integration-test phase to execute.


File Location

The Failsafe Plugin generates reports in file (Txt and XML) By default, these files are generated at ${basedir}/target/failsafe-reports. (where basedir is the project home)


The schema for the Surefire XML reports is available at Surefire XML Report Schema.


For an HTML format of the report, please see the Maven Surefire Report Plugin.

Test shared between multiple module

Powered by ComboStrap