实践maven-failsafe-plugin

Maven Failsafe Plugin用于集成测试

1
2
3
4
5
6
7
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-failsafe-plugin</artifactId>
	<configuration>
		<skip>true</skip>
	</configuration>
</plugin>
1
2
3
4
5
<includes>
    <include>**/IT*.java</include>
    <include>**/*IT.java</include>
    <include>**/*ITCase.java</include>
</includes>

QA

what is the different between maven-surefire-plugin and mave-failsafe-plugin?

  • maven-surefire-plugin is designed for running unit tests and if any of the tests fail then it will fail the build immediately.

  • maven-failsafe-plugin is designed for running integration tests, and decouples failing the build if there are test failures from actually running the tests.

    The name “failsafe” was chosen both because it is a synonym of surefire and because it implies that when it fails, it does so in a safe way.

    The Failsafe Plugin has two goals:

参见Maven FAQ