結果聚合器

public class ResultAggregator
extends CollectingTestListener

java.lang.Object
com.android.tradefed.result.CollectingTestListener
com.android.tradefed.retry.ResultAggregator


特殊轉發器,根據所採取的重試策略,在需要時聚合結果。

概括

公共構造函數

ResultAggregator ( listeners, RetryStrategy strategy) ResultAggregator ( listeners, RetryStrategy strategy)

公共方法

void cleanEventsFiles ()
final void forwardAggregatedInvocationLogs ()

將所有調用級別日誌轉發到不支持粒度結果的結果報告器。

void invocationEnded (long elapsedTime)

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

void invocationFailed ( FailureDescription failure)

void invocationFailed (Throwable cause)

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

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 setLogSaver ( ILogSaver logSaver)

void setUpdatedReporting (boolean updatedReporting)

設置新的報告。

void testAssumptionFailure ( TestDescription test, String trace)

當原子測試標記其假定條件為 false 時調用

void testAssumptionFailure ( TestDescription test, FailureDescription failure)

當原子測試標記其假定條件為 false 時調用

void testEnded ( TestDescription test, long endTime, testMetrics) testEnded ( TestDescription test, long endTime, testMetrics)

ERROR(/#testEnded(com.android.tradefed.result.TestDescription,Map))的替代方案,我們可以直接指定結束時間。

void testFailed ( TestDescription test, FailureDescription failure)

報告單個測試用例的失敗。

void testFailed ( TestDescription test, String trace)

報告單個測試用例的失敗。

void testIgnored ( TestDescription test)

當測試不會運行時調用,通常是因為測試方法用 org.junit.Ignore 註解。

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 errorMessage)

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

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

報告測試運行的開始。

void testStarted ( TestDescription test, long startTime)

testStarted(com.android.tradefed.result.TestDescription)的替代方案,其中我們還指定測試開始時間,並結合ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,Map))進行準確測量。

受保護的方法

File[] getEventsLogs ()

公共構造函數

結果聚合器

public ResultAggregator ( listeners, 
                RetryStrategy strategy)

參數
listeners

strategy RetryStrategy

公共方法

清理事件文件

public void cleanEventsFiles ()

轉發聚合調用日誌

public final void forwardAggregatedInvocationLogs ()

將所有調用級別日誌轉發到不支持粒度結果的結果報告器。

調用結束

public void invocationEnded (long elapsedTime)

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

將由 TradeFederation 框架自動調用。

參數
elapsedTime long :調用所用的時間(以毫秒為單位)

調用失敗

public void invocationFailed (FailureDescription failure)

參數
failure FailureDescription

調用失敗

public void invocationFailed (Throwable cause)

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

將由 TradeFederation 框架自動調用。

參數
cause Throwable :失敗的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 ,應與測試用例關聯。

設置日誌保存程序

public void setLogSaver (ILogSaver logSaver)

參數
logSaver ILogSaver

設置更新報告

public void setUpdatedReporting (boolean updatedReporting)

設置新的報告。

參數
updatedReporting boolean

測試假設失敗

public void testAssumptionFailure (TestDescription test, 
                String trace)

當原子測試標記其假定條件為 false 時調用

參數
test TestDescription :標識測試

trace String : 失敗的堆棧跟踪

測試假設失敗

public void testAssumptionFailure (TestDescription test, 
                FailureDescription failure)

當原子測試標記其假定條件為 false 時調用

參數
test TestDescription :標識測試

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

測試結束

public void testEnded (TestDescription test, 
                long endTime, 
                 testMetrics)

ERROR(/#testEnded(com.android.tradefed.result.TestDescription,Map))的替代方案,我們可以直接指定結束時間。與testStarted(com.android.tradefed.result.TestDescription, long)結合使用以進行準確測量。

參數
test TestDescription :標識測試

endTime long :測試結束的時間,通過System.currentTimeMillis()測量

testMetrics :發出的指標的ERROR(/Map)

測試失敗

public void testFailed (TestDescription test, 
                FailureDescription failure)

報告單個測試用例的失敗。

將在 testStarted 和 testEnded 之間調用。

參數
test TestDescription :標識測試

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

測試失敗

public void testFailed (TestDescription test, 
                String trace)

報告單個測試用例的失敗。

將在 testStarted 和 testEnded 之間調用。

參數
test TestDescription :標識測試

trace String : 失敗的堆棧跟踪

測試被忽略

public void testIgnored (TestDescription test)

當測試不會運行時調用,通常是因為測試方法用 org.junit.Ignore 註解。

參數
test TestDescription :標識測試

測試日誌

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

參數
dataName String

dataType LogDataType

dataStream InputStreamSource

測試日誌已保存

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 errorMessage)

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

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

測試運行開始

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

報告測試運行的開始。

參數
name String : 測試運行名稱

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

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

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

測試開始

public void testStarted (TestDescription test, 
                long startTime)

testStarted(com.android.tradefed.result.TestDescription)的替代方案,其中我們還指定測試開始時間,並結合ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,Map))進行準確測量。

參數
test TestDescription :標識測試

startTime long :測試開始的時間,通過System.currentTimeMillis()測量

受保護的方法

獲取事件日誌

protected File[] getEventsLogs ()

退貨
File[]