Maven - Test

Card Puncher Data Processing


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

See Maven - test jar

Discover More
Card Puncher Data Processing
Maven - Lifecycle

A Build Lifecycle is Made Up of Phases. To call all phase, you only need to call the last build phase to be executed, deploy: If you call a build phase, it will execute not only that build phase, but...
Card Puncher Data Processing
Maven - Phase (Build lifecycle)

A phase is a step in the build lifecycle, which is an ordered sequence of phases. When a phase is given, Maven will execute every phase in the sequence up to and including the one defined. Phases are...
Card Puncher Data Processing
Maven - Plugin Development

How to develop a maven plugin with Java Annotation. (It's important for the configuration). The code result of this tutorial is on github. gerardnico/helloworld-maven-pluginhelloworld-maven-plugin ...
Card Puncher Data Processing
Maven - test jar

A test jar is a jar file used to share test code between module. In two steps: Creating the test jar that is shared with the other modules (ie all test class will be package in a test jar) ...

Share this page:
Follow us:
Task Runner