分片監聽器

public class ShardListener
extends CollectingTestListener implements ISupportGranularResults

java.lang.Object
com.android.tradefed.result.CollectingTestListener
com.android.tradefed.invoker.ShardListener


從呼叫分片(也稱為在多個資源上並行運行的呼叫分割)收集結果的ITestInvocationListener ,並將它們轉送到另一個偵聽器。

概括

公共構造函數

ShardListener ( ITestInvocationListener main)

建立一個ShardListener

公共方法

getUnderlyingResultReporter ()
void invocationEnded (long elapsedTime)

報告呼叫已終止,無論是成功還是由於某些錯誤情況。

void invocationFailed ( FailureDescription failure)

由於某些錯誤情況而報告不完整的呼叫。

void invocationFailed (Throwable cause)

由於某些錯誤情況而報告不完整的呼叫。

void invocationSkipped ( SkipReason reason)

將呼叫報告為已跳過

void invocationStarted ( IInvocationContext context)

報告測試調用的開始。

void logAssociation (String dataName, LogFile logFile)

在某些情況下,日誌必須與測試案例強關聯,但有機會這樣做就直接testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile)回呼是不可能的。

void setSupportGranularResults (boolean enableGranularResults)
boolean supportGranularResults ()

如果報告器支援精細結果,則傳回 True,否則傳回 false。

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

提供來自測試調用的關聯日誌或調試資料。

void testLogSaved (String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)

void testModuleEnded ()

報告模組運作結束。

void testModuleStarted ( IInvocationContext moduleContext)

報告模組運作的開始。

void testRunEnded (long elapsedTime, runMetrics) testRunEnded (long elapsedTime, runMetrics)

報告測試運行結束。

void testRunFailed ( FailureDescription failure)

報告測試運行由於FailureDescription描述的故障而未能完成。

void testRunFailed (String failureMessage)

報告測試運行因致命錯誤而未能完成。

void testRunStarted (String name, int numTests, int attemptNumber, long startTime)

報告測試運行的開始。

公共構造函數

分片監聽器

public ShardListener (ITestInvocationListener main)

建立一個ShardListener

參數
main ITestInvocationListener :應該轉發結果的ITestInvocationListener 。為了防止與其他ShardListener發生衝突,該物件在轉送結果時將在main上同步。並且只有在呼叫分片完成後才會發送結果。

公共方法

取得底層結果報告器

public  getUnderlyingResultReporter ()

退貨

呼叫結束

public void invocationEnded (long elapsedTime)

報告呼叫已終止,無論是成功還是由於某些錯誤情況。

將由 TradeFederation 框架自動呼叫。

參數
elapsedTime long :呼叫所花費的時間(以毫秒為單位)

呼叫失敗

public void invocationFailed (FailureDescription failure)

由於某些錯誤情況而報告不完整的呼叫。

將由 TradeFederation 框架自動呼叫。

參數
failure FailureDescription :描述失敗原因的FailureDescription

呼叫失敗

public void invocationFailed (Throwable cause)

由於某些錯誤情況而報告不完整的呼叫。

將由 TradeFederation 框架自動呼叫。

參數
cause Throwable :失敗的Throwable原因

呼叫已跳過

public void invocationSkipped (SkipReason reason)

將呼叫報告為已跳過

參數
reason SkipReason

調用開始

public void invocationStarted (IInvocationContext context)

報告測試調用的開始。

將由 TradeFederation 框架自動呼叫。記者需要重寫此方法以支援多設備報告。

參數
context IInvocationContext :有關呼叫的信息

日誌關聯

public void logAssociation (String dataName, 
                LogFile logFile)

在某些情況下,日誌必須與測試案例強關聯,但有機會這樣做就直接testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile)回呼是不可能的。因此,此回調允許明確提供強關聯。

參數
dataName String : 資料的名稱

logFile LogFile :先前記錄的LogFile ,應與測試案例關聯。

設定支援粒度結果

public void setSupportGranularResults (boolean enableGranularResults)

參數
enableGranularResults boolean

支援粒度結果

public boolean supportGranularResults ()

如果報告器支援精細結果,則傳回 True,否則傳回 false。

退貨
boolean

測試日誌

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 testLogSaved (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream, 
                LogFile logFile)

參數
dataName String

dataType LogDataType

dataStream InputStreamSource

logFile LogFile

測試模組結束

public void testModuleEnded ()

報告模組運作結束。

測試模組啟動

public void testModuleStarted (IInvocationContext moduleContext)

報告模組運作的開始。此回調與testModuleEnded()關聯,並且在序列中是可選的。它僅在使用模組的運行期間使用:基於套件的運行器。

參數
moduleContext IInvocationContext :模組的IInvocationContext

測試運行結束

public void testRunEnded (long elapsedTime, 
                 runMetrics)

報告測試運行結束。 FIXME:我們不能有兩個不同類型的 Map<> 接口,所以我們必須在這裡使用 HashMap。

參數
elapsedTime long :設備報告的經過時間,以毫秒為單位

runMetrics :使用Metric測試運行結束時報告的鍵值對。

測試運行失敗

public void testRunFailed (FailureDescription failure)

報告測試運行由於FailureDescription描述的故障而未能完成。

參數
failure FailureDescription :描述故障及其上下文的FailureDescription

測試運行失敗

public void testRunFailed (String failureMessage)

報告測試運行因致命錯誤而未能完成。

參數
failureMessage String :描述運行失敗原因的String

測試運行開始

public void testRunStarted (String name, 
                int numTests, 
                int attemptNumber, 
                long startTime)

報告測試運行的開始。

參數
name String : 測試運行名稱

numTests int : 測試運行中的測試總數

attemptNumber int :訂單編號,標識相同 runName 多次執行的不同嘗試。 attemptsNumber 是從 0 開始索引的,並且每次新的運行發生時都應該遞增。例如,一個測試被粒度重試 3 次,它應該在同一 runName 下總共運行 4 次,並且 attemptsNumber 從 0 到 3。

startTime long :運行開始的時間,透過System.currentTimeMillis()測量