如何在Gradle任务中配置TestNG Reporter参数

如何在Gradle任务中配置TestNG Reporter参数,testng,gradle,Testng,Gradle,我正在通过Gradle执行TestNG测试。我想为默认XMLReporter配置StackTraceOutpMethod的值 这是我的毕业任务 // runs test cases using TestNG framework task runTests(type: JavaExec, dependsOn: classes) { main = 'org.testng.TestNG' args '-reporter org.testng.reporters.XMLReporter:st

我正在通过Gradle执行TestNG测试。我想为默认XMLReporter配置StackTraceOutpMethod的值

这是我的毕业任务

// runs test cases using TestNG framework
task runTests(type: JavaExec, dependsOn: classes) {
   main = 'org.testng.TestNG'
   args '-reporter org.testng.reporters.XMLReporter:stackTraceOutputMethod="0" testng.xml'
   classpath configurations.runtime
   systemProperties 'logDir': 'logs'
}
我得到以下错误:

15:30:36.343 [ERROR] [system.err] Unknown option: -reporter org.testng.reporters.XMLReporter:stackTraceOutputMethod=0 testng.xml 15:30:36.390 [QUIET] [system.out] Usage: [options] The XML suite files to run Options: -configfailurepolicy Configuration failure policy (skip or continue) -d Output directory -dataproviderthreadcount Number of threads to use when running data providers -excludegroups Comma-separated list of group names to exclude . . . 15:30:36.343[ERROR][system.err]未知选项:-reporter org.testng.reporters.XMLReporter:stackTraceOutputMethod=0 testng.xml 15:30:36.390[QUIET][system.out]用法:[选项]要运行的XML套件文件 选项: -配置失败策略配置失败策略(跳过或 (续) -d输出目录 -dataproviderthreadcount运行时要使用的线程数 数据提供者 -excludegroups以逗号分隔的组名列表 排除 . . . 我想我提供Java参数的方式是不正确的

args '-reporter org.testng.reporters.XMLReporter:stackTraceOutputMethod="0" testng.xml' args'-reporter org.testng.reporters.XMLReporter:stackTraceOutputMethod=“0”testng.xml” 有人能告诉我正确的方法是什么吗


谢谢

传递多个参数的正确方法是:

args '-reporter','....','testng.xml'
所以每个参数都有自己的字符串。而不是将所有空间分开传递

更新

TestNG实际上很容易在Gradle中配置,我建议您使用以下方法:

task runTests(type: Test) {
    useTestNG()
    options {
        listeners << '...'
    }
}
任务运行测试(类型:测试){
useTestNG()
选择权{

我尝试的侦听器
args'-reporter''org.testng.reporters.XMLReporter',stackTraceOutputMethod=0',testng.xml'

出现以下错误:
生成失败,出现异常。
启动失败:
生成文件“D:\R43_playit\demoProject\Build.gradle”:23:应为“}“,”找到“,”@第23行,第56列。您能发布更新的gradle构建文件吗,您在某处有语法错误…//使用TestNG框架任务运行测试运行测试(类型:JavaExec,dependsOn:classes){main='org.TestNG.TestNG'args'TestNG.xml'classpath configurations.runtime systemProperties'logDir':'logs}aneez,你能使用格式吗?这样更容易阅读,第22行和第23行是什么?
//使用TestNG框架任务运行测试运行测试(类型:JavaExec,dependsOn:classes){main='org.TestNG.TestNG'args'TestNG.xml'classpath configurations.runtime systemProperties'logDir':'logs'}/code>