TestFailureListener
public
class
TestFailureListener
extends Object
implements
ITestInvocationListener
java.lang.Object | |
↳ | com.android.tradefed.testtype.suite.TestFailureListener |
事件監聽器,用於在測試失敗時 (在要求時) 執行螢幕截圖、錯誤報告和 Logcat 收集等動作。
摘要
公用建構函式 | |
---|---|
TestFailureListener(
|
公用方法 | |
---|---|
void
|
applyModuleConfiguration(boolean bugreportOnFailure)
允許您透過模組專屬設定,覆寫失敗時擷取的叫用設定。 |
void
|
join()
加入所有 Logcat 擷取執行緒,確保這些執行緒結束。 |
void
|
setLogger(ITestLogger logger)
設定記錄檔的儲存位置。 |
void
|
testFailed(TestDescription test, String trace)
回報個別測試案例的失敗情形。 |
void
|
testLog(String dataName, LogDataType dataType, InputStreamSource dataStream)
提供測試叫用作業的相關記錄或偵錯資料。 |
void
|
testLogForward(String dataName, LogDataType dataType, InputStreamSource dataStream)
將記錄轉送至記錄器,請勿在 #testLog 回呼中執行此操作,因為如果 TestFailureListener 是鏈結的一部分,這會導致無限迴圈。 |
公用建構函式
TestFailureListener
public TestFailureListener (devices, boolean bugReportOnFailure, boolean rebootOnFailure)
參數 | |
---|---|
devices |
|
bugReportOnFailure |
boolean |
rebootOnFailure |
boolean |
公用方法
applyModuleConfiguration
public void applyModuleConfiguration (boolean bugreportOnFailure)
允許您透過模組專屬設定,覆寫失敗時擷取的叫用設定。
參數 | |
---|---|
bugreportOnFailure |
boolean :如果為 true,則會在測試失敗時擷取錯誤報告。否則為 False。 |
加入
public void join ()
加入所有 Logcat 擷取執行緒,確保這些執行緒結束。
testFailed
public void testFailed (TestDescription test, String trace)
回報個別測試案例的失敗情形。
會在 testStarted 和 testEnded 之間呼叫。
參數 | |
---|---|
test |
TestDescription :用於識別測試 |
trace |
String :失敗的堆疊追蹤 |
testLog
public void testLog (String dataName, LogDataType dataType, InputStreamSource dataStream)
提供測試叫用作業的相關記錄或偵錯資料。
必須在 ERROR(/ITestInvocationListener#invocationFailed(Throwable))
或 ERROR(/ITestInvocationListener#invocationEnded(long))
之前呼叫
TradeFederation 架構會自動呼叫這個方法,提供主機記錄,並在適用情況下提供裝置 Logcat。
參數 | |
---|---|
dataName |
String :資料的String 描述性名稱,例如「device_logcat」。請注意,每個叫用作業的 dataName 可能不具唯一性。也就是說,實作者必須能夠處理具有相同 dataName 的多個呼叫 |
dataType |
LogDataType :資料的 LogDataType |
dataStream |
InputStreamSource :資料的 InputStreamSource 。實作者應呼叫 createInputStream 開始讀取資料,並確保在完成時關閉產生的 InputStream。呼叫端應確保資料來源持續存在且可供存取,直到 testLog 方法完成為止。 |
testLogForward
public void testLogForward (String dataName, LogDataType dataType, InputStreamSource dataStream)
將記錄轉送至記錄器,請勿在 #testLog 回呼中執行此操作,因為如果 TestFailureListener 是鏈結的一部分,這會導致無限迴圈。
參數 | |
---|---|
dataName |
String |
dataType |
LogDataType |
dataStream |
InputStreamSource |