Question

J'utilise TestNG + ReportNG par wiki instructions gradle (je fixe sur livre de cuisine comme exemple par défaut n'a pas sous forme de travail me).

Je voudrais en quelque sorte capturer la sortie de la console dans TestNG. Est-ce possible?

Merci Misha

Était-ce utile?

La solution

Ok, je ne sais toujours pas comment faire formellement cela, mais je viens de rediriger la sortie standard et erreur:

/**
 * 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)
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top