測試失敗監聽器

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 :資料的String描述性名稱。例如“device_logcat”。注意 每次呼叫時 dataName 可能不是唯一的。即實現者必須能夠處理具有相同 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