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)
建立 |
|
公用方法 | |
|---|---|
List<ITestInvocationListener>
|
getUnderlyingResultReporter()
|
void
|
invocationEnded(long elapsedTime)
回報是否因某種錯誤狀況而終止呼叫 (無論是否成功)。 |
void
|
invocationFailed(FailureDescription failure)
Reports an incomplete invocation due to some error condition. |
void
|
invocationFailed(Throwable cause)
Reports an incomplete invocation due to some error condition. |
void
|
invocationSkipped(SkipReason reason)
回報已略過的叫用 |
void
|
invocationStarted(IInvocationContext context)
Reports the start of the test invocation. |
void
|
logAssociation(String dataName, LogFile 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, HashMap<String, MetricMeasurement.Metric> runMetrics)
Reports end of test run. |
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
public List<ITestInvocationListener> getUnderlyingResultReporter ()
| 傳回 | |
|---|---|
List<ITestInvocationListener> |
|
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,LogDataType,InputStreamSource,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)/ITestInvocationListener#invocationFailed(java.lang.Throwable) 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,
HashMap<String, MetricMeasurement.Metric> runMetrics)測試執行結束時會回報。FIXME:我們無法使用不同型別的兩個 Map<> 介面,因此必須在此使用 HashMap。
| 參數 | |
|---|---|
elapsedTime |
long:裝置回報的經過時間 (以毫秒為單位) |
runMetrics |
HashMap:在測試執行結束時,使用 Metric 報告的鍵/值組合。 |
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 為索引,每次執行新作業時都應遞增。舉例來說,如果測試精細重試 3 次,則在相同 runName 下應有 4 次執行,且 attemptNumber 為 0 到 3。 |
startTime |
long:跑步開始時間,透過 System.currentTimeMillis() 測量 |