測試失敗監聽器

public class TestFailureListener
extends Object implements ITestInvocationListener

java.lang.Object
com.android.tradefed.testtype.suite.TestFailureListener


偵聽器過去常常在請求時在測試失敗時採取屏幕截圖、錯誤報告、logcat 收集等操作。

概括

公共構造函數

TestFailureListener ( devices, boolean bugReportOnFailure, boolean rebootOnFailure) TestFailureListener ( devices, boolean bugReportOnFailure, boolean rebootOnFailure)

公共方法

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 是鏈的一部分一樣,這將導致無限循環。

公共構造函數

測試失敗監聽器

public TestFailureListener ( devices, 
                boolean bugReportOnFailure, 
                boolean rebootOnFailure)

參數
devices

bugReportOnFailure boolean

rebootOnFailure boolean

公共方法

應用模塊配置

public void applyModuleConfiguration (boolean bugreportOnFailure)

允許通過模塊特定配置覆蓋失敗時捕獲的調用設置。

參數
bugreportOnFailure boolean : true 捕獲測試失敗的錯誤報告。否則為假。

加入

public void join ()

加入所有 logcat 捕獲線程以確保它們終止。

設置記錄器

public void setLogger (ITestLogger logger)

設置應保存日誌的位置。

參數
logger ITestLogger

測試失敗

public void testFailed (TestDescription test, 
                String trace)

報告單個測試用例的失敗。

將在 testStarted 和 testEnded 之間調用。

參數
test TestDescription :標識測試

trace String :失敗的堆棧跟踪

測試日誌

public void testLog (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream)

提供來自測試調用的關聯日誌或調試數據。

必須在ERROR(/ITestInvocationListener#invocationFailed(Throwable))ERROR(/ITestInvocationListener#invocationEnded(long))之前調用

TradeFederation 框架將自動調用此方法,提供主機日誌和設備 logcat(如果適用)。

參數
dataName String :數據的ERROR(/String)描述性名稱。例如“device_logcat”。注意 dataName 每次調用可能不是唯一的。即實現者必須能夠處理具有相同數據名的多個調用

dataType LogDataType :數據的LogDataType

dataStream InputStreamSource :數據的InputStreamSource 。實施者應調用 createInputStream 開始讀取數據,並確保在完成後關閉生成的 InputStream。調用者應確保數據源保持存在且可訪問,直到 testLog 方法完成。

測試日誌轉發

public void testLogForward (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream)

將日誌轉發到記錄器,不要從 #testLog 回調中開始,就好像 TestFailureListener 是鏈的一部分一樣,這將導致無限循環。

參數
dataName String

dataType LogDataType

dataStream InputStreamSource