我使用每维基指令的gradle中的(I固定在菜谱作为默认实例没有工作形式我)。

我想在某种程度上TestNG的捕获控制台输出。这是可能的?

感谢您 米莎

有帮助吗?

解决方案

好吧,我仍然不知道如何正式做到这一点,但我只是重定向标准输出和错误:

/**
 * 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