我想在现有套件xml文件gradle 自定义任务中设置参数thread-count,类型为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?我如何从exml xml文件创建套件对象?