我想在现有套件 xml 文件 gradle自定义任务中设置参数线程数,类型为 Test。我想设置 useTestNG 然后使用TestNG.class进行测试
String sourceDir = "src"
String resourcesPath = sourceDir.concat("/test/resources")
sourceSets {
test {
java {
srcDirs = [sourceDir]
}
resources {
srcDirs = [resourcesPath]
}
}
}
apply plugin: 'java'
dependencies {
compile project(':core')
compile group: 'org.testng', name: 'testng', version: '6.1.1'
}
task customTask(type: Test) {
useTestNG {
String threads = System.getenv("THREADS")
String suiteName = System.getenv("SUITE")
useDefaultListeners = true
testLogging {
events "passed", "skipped", "failed"
}
}
//What I trying to do, but i have no acces to testng package
TestNG tng = new TestNG();
tng.setXmlSuites(suiteName);
tng.setThreadCount(threads)
tng.run();
}
那么如何使用现有的 xml testng 套件添加参数线程数?我是否创建了 TestNG 实例,从现有文件设置套件并设置 threadCount?以及如何从现有的 xml 文件创建套件对象?