Frage

Ich bin mit TestNG + ReportNG pro Wiki Anweisungen in gradle (I auf Kochbuch fixiert als Standard Beispiel mich nicht Arbeit Form haben).

Ich möchte irgendwie Capture Konsolenausgabe in TestNG. Ist das möglich?

Danke Misha

War es hilfreich?

Lösung

Ok, ich habe immer noch keine Ahnung, wie formal, dies zu tun, aber ich nur die Standardausgabe und Fehler umgeleitet:

/**
 * 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)
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top