maven - 使用组和 dataProvider 值运行时跳过 TestNG 测试
问题描述
使用以下代码跳过测试,
@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
解决方案
-Dgroups=sanity
在 Maven 命令行上,除了定义要在项目的 POM 中使用的属性外,什么都不做。
要定义要测试的组,您必须相应地为 Surefire 插件声明它们:
<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 ...
没有必要,因为调用 Maven 的阶段无论如何都会install
通过test
阶段。
推荐阅读
- swift - 如何使用 UIButton 刷新静态表中的 UITextField 和 UILabel
- heroku - 我的 vue.js + Sails.js 应用程序无法在 Heroku 上运行
- mysql - 在单个分区中查询记录非常慢
- chef-infra - 使用打包程序覆盖厨师客户端中的角色属性
- c# - 我可以使用 log4net 或 Nlog 来捕获 sql 查询错误吗
- python - 如何在 Azure Redhat Linux VM 上更新 python?
- git - '-text' 或 'text eol=lf' 是否更适合 .gitattributes 中的 *.sh 文件?
- c++ - CRTP 共享指针的 C++ 向量
- python - 如何更改 read_csv 对空值的处理
- cassandra - DataStax DSBulk - 查询/表卸载之间的区别