Gradle command syntax for executing TESTNG tests as a group

 ̄綄美尐妖づ 提交于 2019-12-24 07:52:34

问题


I have some tests as below:

@Test(groups={"smoke"})
public void Test1(){...}

@Test(groups={"smoke", "regression"})
public void Test2(){...}

@Test(groups={"regression"})
public void Test3(){...}

In build.gradle file I have below:

task smoketests(type: Test){
useTestNG() {
   suites "src/test/resources/testng.xml"
   includeGroups "smoke"
}

}

I need to have a gradle syntax to run the smoke/regression tests only using commandline. I have tried this:

./gradlew clean test -P testGroups="smoke"

if I run that, build is successful as below:

:clean
:compileJava
:processResources UP-TO-DATE
:classes
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
BUILD SUCCESSFUL
Total time: 42.253 secs

But it never execute actual tests. Need help


回答1:


You have created a custom test task, so you need to use that instead of test in your command line:

gradlew clean smoketests


来源:https://stackoverflow.com/questions/49563007/gradle-command-syntax-for-executing-testng-tests-as-a-group

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!