Wednesday, November 21, 2012

Maven Failsafe Plugin

The Failsafe Plugin is designed to run integration tests while the Surefire Plugins is designed to run unit tests.


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.
The Failsafe Plugin 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.


The Failsafe Plugin generates reports in 2 different file formats:
  • Plain text files (*.txt)
  • XML files (*.xml)
By default, these files are generated at ${basedir}/target/failsafe-reports.
The Failsafe Plugin has only 2 goals:

    <profile>
      <id>integration-test</id>

      <build>
        <plugins>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${maven-failsafe-plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

No comments:

Post a Comment