本文介绍了从命令行使用Gradle运行特定的TestNG XML测试套件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将Gradle与TestNG一起使用.我有这个build.gradle:
I am using Gradle with TestNG. I have this build.gradle:
useTestNG() {
useDefaultListeners = true
suites "src/test/resources/tests1.xml"
suites "src/test/resources/tests2.xml"
}
}
如何仅从命令行运行例如tests1.xml?
How can I run for example only tests1.xml from command line?
推荐答案
,您可以使用项目属性来添加/更改/...不同的套件.在您的示例中,您可能正在运行
you can use project properties to add/change/... different suites. In you example you are probably running
gradlew test
同时运行两个套件.如果您在build.gradle
which run both suites. If you modify test task in your build.gradle
def suite1 = project.hasProperty("suite1")
def suite2 = project.hasProperty("suite2")
test {
useTestNG() {
dependsOn cleanTest
useDefaultListeners = true
if(suite1) {
suites "src/test/resources/simpleSuite.xml"
}
if(suite2) {
suites "src/test/resources/advancedSuite.xml"
}
}
}
您可以通过这种方式选择套房
you can choose suite in this way
gradlew test -Psuite1
gradlew test -Psuite2
gradlew test -Psuite1 -Psuite2
这篇关于从命令行使用Gradle运行特定的TestNG XML测试套件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!