开发者

testng and gradle - see output from deadlocked tests?

开发者 https://www.devze.com 2023-01-03 02:04 出处:网络
If I have a test that hangs I don\'t seem to get any results. Is there any way to see out开发者_StackOverflow中文版put live?

If I have a test that hangs I don't seem to get any results.

Is there any way to see out开发者_StackOverflow中文版put live?

Thank you Misha


Ok I still have no idea how to formally do this but I just redirected standard output and error:

/**
 * Redirect standard output and error to appropriate files
 */
public void redirectStandardOutputAndErrorToFiles(className) {
  def outFile=new   File(System.getProperty("java.io.tmpdir")+File.separator+className+".out.log")
  if (outFile.exists()) {
    outFile.delete()
  }
  def errFile=new File(System.getProperty("java.io.tmpdir")+File.separator+className+".err.log")
  if (errFile.exists()) {
    errFile.delete()
  }
  def out=new PrintStream(new FileOutputStream(outFile))
  def err=new PrintStream(new FileOutputStream(errFile))
  System.setOut(out)
  System.setErr(err)
}


You can add the following directive to the test task to tell it to output the standard streams:

build.gradle:

test {
    testLogging.showStandardStreams = true
}
0

精彩评论

暂无评论...
验证码 换一张
取 消