分片監聽器
public class ShardListener
extends CollectingTestListener
implements ISupportGranularResults
java.lang.Object | ||
↳ | com.android.tradefed.result.CollectingTestListener | |
↳ | com.android.tradefed.invoker.ShardListener |
一個ITestInvocationListener
,它從調用分片(又名調用拆分以並行運行在多個資源上)收集結果,並將它們轉發給另一個偵聽器。
概括
公共構造函數 | |
---|---|
ShardListener ( ITestInvocationListener main) 創建一個 |
公共方法 | |
---|---|
getUnderlyingResultReporter () | |
void | invocationEnded (long elapsedTime) 報告調用已終止,無論是成功終止還是由於某些錯誤情況。 |
void | invocationFailed ( FailureDescription failure) 報告由於某些錯誤情況導致的不完整調用。 |
void | invocationFailed (Throwable cause) 報告由於某些錯誤情況導致的不完整調用。 |
void | invocationStarted ( IInvocationContext context) 報告測試調用的開始。 |
void | logAssociation (String dataName, LogFile logFile) 在某些情況下,日誌必須與測試用例強關聯,但有機會這樣做就直接 |
void | setSupportGranularResults (boolean enableGranularResults) |
boolean | supportGranularResults () 如果 reporter 支持粒度結果,則返回 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) 由於 |
void | testRunFailed (String failureMessage) 報告測試運行由於致命錯誤而未能完成。 |
void | testRunStarted (String name, int numTests, int attemptNumber, long startTime) 報告測試運行的開始。 |
公共構造函數
分片監聽器
public ShardListener (ITestInvocationListener main)
創建一個ShardListener
。
參數 | |
---|---|
main | ITestInvocationListener :應轉發ITestInvocationListener 結果。為防止與其他ShardListener 發生衝突,此對象將在轉發結果時在main上同步。結果只會在調用分片完成後發送。 |
公共方法
getUnderlyingResultReporter
publicgetUnderlyingResultReporter ()
退貨 | |
---|---|
調用結束
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 : 失敗的ERROR(/Throwable) 原因 |
調用開始
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 ,應該與測試用例相關聯。 |
setSupportGranularResults
public void setSupportGranularResults (boolean enableGranularResults)
參數 | |
---|---|
enableGranularResults | boolean |
支持粒度結果
public boolean supportGranularResults ()
如果 reporter 支持粒度結果,則返回 True,否則返回 false。
退貨 | |
---|---|
boolean |
測試日誌
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 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 : ERROR(/String) 描述運行失敗的原因。 |
測試運行開始
public void testRunStarted (String name, int numTests, int attemptNumber, long startTime)
報告測試運行的開始。
參數 | |
---|---|
name | String : 測試運行名稱 |
numTests | int : 測試運行中的測試總數 |
attemptNumber | int : order number,標識同一 runName 多次運行的不同嘗試。 attemptNumber 是從 0 開始索引的,每次發生新的運行時都應該遞增。例如,一個測試被精細地重試了 3 次,它應該在相同的 runName 下總共運行 4 次,並且 attemptNumber 是從 0 到 3。 |
startTime | long :運行開始的時間,通過ERROR(/System#currentTimeMillis()) 測量 |