0
votes

I am executing TestNG tests via Gradle. I want to configure the value of stackTraceOutputMethod for the default XMLReporter.

This is my Gradle task

// 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'
}

I am getting the following error:

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
.
.
.

I guess the way I am providing the Java args is incorrect.

args '-reporter org.testng.reporters.XMLReporter:stackTraceOutputMethod="0" testng.xml'

Can somebody let me know what is the correct way to do it ?

Thanks

1

1 Answers

1
votes

The correct way of passing multiple args is:

args '-reporter','....','testng.xml'

So each argument goes in its own string. Instead of passing them all space-separated.

Update

TestNG is actually pretty easy to configure in Gradle, I'd suggest you use the following:

task runTests(type: Test) {
    useTestNG()
    options {
        listeners << '...'
    }
}