3

GradleでWiki命令ごとにTestNG+ReportNGを使用しています(デフォルトの例が機能しなかったため、クックブックで修正しました)。

どういうわけかTestNGでコンソール出力をキャプチャしたいと思います。これは可能ですか?

ありがとうミーシャ

4

1 に答える 1

3

わかりました。これを正式に行う方法はまだわかりませんが、標準出力とエラーをリダイレクトしただけです。

/**
 * 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)
}
于 2010-06-14T04:39:53.850 に答える