Gradle TestNG results output

2019-02-20 18:12发布

问题:

I can't seem to figure out how to configure log output and results folders for Gradle TestNG runs.

First, Gradle picks $project_dir/build/reports/tests by default for HTML report output. How do I change this default location? I tried setting testReportDir in build.gradle to no avail. Specifying a map in call to useTestNG(), e.g.

test {
   if (runTest) {
      // enable TestNG support (default is JUnit)
      useTestNG {
         outputDirectory = file("$buildDir/test-output")
      }
   }
}

does not work as well.

Second, I tried using TestNG's Reporter for some additional logging, e.g:

@Test
public void testMethod() {
   parseFile();
   Reporter.log("File parsed");
   Assert.assertTrue(...);
}

But I can't seem to find the logs! Can someone please help?

回答1:

The testReportDir property is read-only. You'll need to set Project.testReportDirName. You should be able to enable test logging like so.

test {
    testLogging.showStandardStreams = true
}