以下代码跳过测试,
@Test(groups = { "sanity", "prod" }, dataProviderClass = ReqRespDataProvider.class, dataProvider = "sampleTestData")
public void sampleMethodTest(Map<DataType, String> map){
}
跑步
mvn clean install test -Dgroups=sanity
结果:
Running TestSuite
Tests run: 2, Failures: 0, Errors: 0, Skipped: 2, Time elapsed: 5.426 sec
Maven命令行上的-Dgroups=sanity
除了定义要在项目的POM中使用的属性外什么都不做。
要定义要测试的组,必须使用declare them for the Surefire Plugin accordingly:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<groups>${groups}</groups>
</configuration>
</plugin>
顺便说一句,... install test ...
是没有必要的,因为invoking Maven's install
phase passes the test
phase anyway。
找到了解决方案。使用groups标签运行测试时跳过@BeforeSuite方法。我已经更改了@BeforeSuite(alwaysRun = true)并且所有组标记的测试都在运行中被选中。