控制台結果報告器

public class ConsoleResultReporter
extends TestResultListener implements ILogSaverListener , ITestInvocationListener

java.lang.Object
com.android.tradefed.result.TestResultListener
com.android.tradefed.result.ConsoleResultReporter


結果報告器將測試結果列印到控制台。

列印每個測試運行、每個測試案例以及測試指標、測試日誌和測試文件位置。

概括

公共構造函數

ConsoleResultReporter ()

公共方法

void invocationEnded (long elapsedTime)

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

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

保存測試日誌時調用。

void testResult ( TestDescription test, TestResult result)
void testRunEnded (long elapsedTimeMillis, metrics) testRunEnded (long elapsedTimeMillis, metrics)

報告測試運行結束。

void testRunFailed ( FailureDescription failure)

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

void testRunFailed (String errorMessage)

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

void testRunStarted (String runName, int testCount)

報告測試運行的開始。

公共構造函數

控制台結果報告器

public ConsoleResultReporter ()

公共方法

呼叫結束

public void invocationEnded (long elapsedTime)

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

將由 TradeFederation 框架自動呼叫。

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

調用開始

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

保存測試日誌時調用。

應該用來取代ITestInvocationListener#testLog(String, LogDataType, InputStreamSource)

參數
dataName String :資料的String描述性名稱。例如“device_logcat”。注意 每次呼叫時 dataName 可能不是唯一的。即實現者必須能夠處理具有相同 dataName 的多個呼叫

dataType LogDataType :資料的LogDataType

dataStream InputStreamSource :資料的InputStreamSource 。實作者應該呼叫 createInputStream 來開始讀取數據,並確保完成後關閉產生的 InputStream。

logFile LogFile :包含已儲存檔案的元資料的LogFile

測試結果

public void testResult (TestDescription test, 
                TestResult result)

參數
test TestDescription

result TestResult

測試運行結束

public void testRunEnded (long elapsedTimeMillis, 
                 metrics)

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

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

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

測試運行失敗

public void testRunFailed (FailureDescription failure)

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

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

測試運行失敗

public void testRunFailed (String errorMessage)

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

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

測試運行開始

public void testRunStarted (String runName, 
                int testCount)

報告測試運行的開始。

參數
runName String : 測試運行名稱

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