I am new to Gradle, but I know in Maven we can run specific profile. In my case, I have 2 TestNG.xml files and in Maven POM.xml I can write like this
<profiles>
<profile>
<id>FirstRegression</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng1.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>SecondRegression</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng2.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
In command line , we can choose which profile (which TestNG.xml file) we want to run.
mvn test -PFirstRegression
will execute our testng1.xml file only, meanwhile
mvn test -pSecondRegresion
will execute our testng2.xml file only.
How can we do this in build.gradle file ? so we can choose which profile to run in gradle.
I can put like this in build.gradle
plugins {
id 'java'
}
test {
useTestNG() {
suites 'testng1.xml'
suites 'testng2.xml'
}
}
But when I run gradle clean build
, it will run both of them.
Is there anyway we can say gradle clean build --"please run testng2.xml only"
? Thank You.