ShardListener
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
|
invocationSkipped(SkipReason reason)
將叫用動作回報為略過 |
void
|
invocationStarted(IInvocationContext context)
回報測試叫用作業的開始時間。 |
void
|
logAssociation(String dataName, LogFile logFile)
在某些情況下,記錄必須與測試案例建立強烈關聯,但無法直接在 |
void
|
setSupportGranularResults(boolean enableGranularResults)
|
boolean
|
supportGranularResults()
如果報表提供詳細結果,則傳回「是」;否則傳回「否」。 |
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,
回報測試執行結束。 |
void
|
testRunFailed(FailureDescription failure)
由於 |
void
|
testRunFailed(String failureMessage)
由於發生致命錯誤,因此無法完成報表測試。 |
void
|
testRunStarted(String name, int numTests, int attemptNumber, long startTime)
回報測試執行作業的開始時間。 |
公用建構函式
ShardListener
public ShardListener (ITestInvocationListener main)
建立 ShardListener。
| 參數 | |
|---|---|
main |
ITestInvocationListener:應轉送結果的 ITestInvocationListener。為避免與其他 ShardListener 發生衝突,此物件會在轉寄結果時在 main 上同步處理。只有在呼叫區塊完成後,系統才會傳送結果。 |
公用方法
getUnderlyingResultReporter
publicgetUnderlyingResultReporter ()
| 傳回 | |
|---|---|
|
|
invocationEnded
public void invocationEnded (long elapsedTime)
回報叫用已終止,無論是成功或因某些錯誤條件而終止。
會由 TradeFederation 架構自動呼叫。
| 參數 | |
|---|---|
elapsedTime |
long:叫用作業的經過時間 (以毫秒為單位) |
invocationFailed
public void invocationFailed (FailureDescription failure)
由於某些錯誤情況,因此回報未完成的叫用作業。
會由 TradeFederation 架構自動呼叫。
| 參數 | |
|---|---|
failure |
FailureDescription:描述失敗原因的 FailureDescription |
invocationFailed
public void invocationFailed (Throwable cause)
由於某些錯誤情況,因此回報未完成的叫用作業。
會由 TradeFederation 架構自動呼叫。
| 參數 | |
|---|---|
cause |
Throwable:失敗的 Throwable 原因 |
invocationStarted
public void invocationStarted (IInvocationContext context)
回報測試叫用作業的開始時間。
會由 TradeFederation 架構自動呼叫。回報器需要覆寫這個方法,才能支援多裝置回報。
| 參數 | |
|---|---|
context |
IInvocationContext:叫用作業相關資訊 |
logAssociation
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 |
supportGranularResults
public boolean supportGranularResults ()
如果回報器支援精細結果,則傳回 True,否則傳回 false。
| 傳回 | |
|---|---|
boolean |
|
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 方法完成為止。 |
testLogSaved
public void testLogSaved (String dataName,
LogDataType dataType,
InputStreamSource dataStream,
LogFile logFile)| 參數 | |
|---|---|
dataName |
String |
dataType |
LogDataType |
dataStream |
InputStreamSource |
logFile |
LogFile |
testModuleEnded
public void testModuleEnded ()
回報模組執行作業結束。
testModuleStarted
public void testModuleStarted (IInvocationContext moduleContext)
回報模組開始執行的時間。這個回呼與 testModuleEnded() 相關聯,在序列中為選用項目。只有在使用模組:套件式執行程式的執行期間才會使用。
| 參數 | |
|---|---|
moduleContext |
IInvocationContext:模組的 IInvocationContext。 |
testRunEnded
public void testRunEnded (long elapsedTime,
runMetrics) 回報測試執行結束。
| 參數 | |
|---|---|
elapsedTime |
long:裝置回報的經過時間,以毫秒為單位 |
runMetrics |
:測試執行結束時回報的鍵/值組合 |
testRunFailed
public void testRunFailed (FailureDescription failure)
由於 FailureDescription 所述的錯誤,導致報表測試執行作業無法完成。
| 參數 | |
|---|---|
failure |
FailureDescription:FailureDescription 可說明失敗和相關情境。 |
testRunFailed
public void testRunFailed (String failureMessage)
由於發生致命錯誤,因此無法完成報表測試執行作業。
| 參數 | |
|---|---|
failureMessage |
String:String,說明執行失敗的原因。 |
testRunStarted
public void testRunStarted (String name,
int numTests,
int attemptNumber,
long startTime)回報測試執行作業的開始時間。
| 參數 | |
|---|---|
name |
String:測試執行作業名稱 |
numTests |
int:測試執行作業中的測試總數 |
attemptNumber |
int:訂單號碼,用於識別同一個 runName 執行多次的不同嘗試。attemptNumber 的索引為 0,每次執行新測試時,應增加 1。舉例來說,如果測試重試 3 次,則在相同的 runName 下,應有 4 次總執行次數,而 attemptNumber 則從 0 到 3。 |
startTime |
long:透過 System.currentTimeMillis() 測量的執行作業開始時間 |