문제

I am using TestNG + ReportNG per wiki instructions in gradle (I fixed on cookbook as default example did not work form me).

I would like to somehow capture console output in TestNG. Is this possible?

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)
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top