maven-surefire-plugin插件的使用
- maven-surefire-plugin的作用
- 用来执行单元测试;
- 在pom.xml中配置junit,TestNG等测试框架的依赖,即可以自动识别和运行src/test目录下利用该框架编写的测试用例;
- surefire也能识别和执行符合一定命名约定的普通类中的测试方法;
- 生命周期中test阶段默认绑定的插件就是surefire中的test目标,无需额外配置,直接运行run test就可以。
- 在pom.xml中引入
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<skipTests>true</skipTests>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
- 功能配置
mvn -Dsurefire.rerunFailingTestsCount=2 test
mvn -Dtest=TestClassName,TestCl*le test
mvn -Dtest=TestCircle