التقاط إخراج وحدة التحكم في testng؟
سؤال
أنا أستخدم Testng + ReportNg لكل ويكي تعليمات في Gradle (أنا ثابت على كتاب الطبخ كمثال افتراضي لم ينجح لي).
أرغب في التقاط إخراج وحدة التحكم بطريقة ما في 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)
}
لا تنتمي إلى StackOverflow