I have checked following questions but none of them helped -
Gradle + TestNG Only Running Specified Group
Gradle command syntax for executing TESTNG tests as a group
The project I am using is available at - https://github.com/tarun3kumar/gradle-demo
It is standard maven project and I am not using testng.xml file.
Test method - com.org.corpsite.LandingPageTest is grouped as - smoke
I am running test as - gradle clean test and test is executed. Test fails due to genuine reason and let's ignore it.
Then I passed test group from command line as -
gradle clean test -P testGroups='doesnotexist'
Notice that 'doesnotexist' is not a valid group but it still executes test.
Following this I added includeGroups in build.gradle as -
test {
useTestNG() {
includeGroups 'smoke'
}
}
and now gradle clean test -P testGroups='doesnotexist' fails with NPE on one of the java class - java.lang.NullPointerException
at com.org.pageobjects.BasePage.findElements(BasePage.java:24)
Questions -
- What is right flag to specify test group from command line? Seems
-Pis wrong elsegradle clean test -P testGroups='doesnotexist'would not execute test. - What is wrong with specifying
includeGroups 'smoke'?
I am using Gradle 5.1 on macbook pro