TextResultReporter

public class TextResultReporter
extends InvocationToJUnitResultForwarder implements ILogSaverListener, ITestInvocationListener

java.lang.Object
   ↳ com.android.tradefed.result.InvocationToJUnitResultForwarder
     ↳ com.android.tradefed.result.TextResultReporter


測試結果回報工具,可將結果轉送至 JUnit 文字結果印表機。

摘要

公用建構函式

TextResultReporter()

建立 TextResultReporter

公用方法

void testAssumptionFailure(TestDescription testId, String trace)

當原子測試標記假設為 false 的條件時,系統會呼叫這個函式

void testEnded(TestDescription testId, HashMap<String, MetricMeasurement.Metric> metrics)

覆寫父項,明確列印測試指標。

void testFailed(TestDescription testId, String trace)

Overrides parent to explicitly print out failures.

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

提供測試呼叫的相關記錄或偵錯資料。

void testLogSaved(String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)

測試記錄儲存完畢時呼叫。

void testRunEnded(long elapsedTime, HashMap<String, MetricMeasurement.Metric> metrics)

覆寫父項,明確列印指標。

公用建構函式

TextResultReporter

public TextResultReporter ()

建立 TextResultReporter

公用方法

testAssumptionFailure

public void testAssumptionFailure (TestDescription testId, 
                String trace)

當原子測試標記假設為 false 的條件時呼叫

參數
testId TestDescription:識別測試

trace String:失敗的堆疊追蹤

testEnded

public void testEnded (TestDescription testId, 
                HashMap<String, MetricMeasurement.Metric> metrics)

覆寫父項,明確列印測試指標。

參數
testId TestDescription:識別測試

metrics HashMap:發出的指標 Map

testFailed

public void testFailed (TestDescription testId, 
                String trace)

覆寫父項,明確列印失敗項目。ResultPrinter 會在測試執行結束時,依據執行器呼叫「print」的結果執行這項操作。回報個別測試案例的失敗情形。

會在 testStarted 和 testEnded 之間呼叫。

參數
testId TestDescription:識別測試

trace String:失敗的堆疊追蹤

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)

測試記錄儲存完畢時呼叫。

應取代 ITestInvocationListener.testLog(String,LogDataType,InputStreamSource) 使用。

參數
dataName String:資料的String說明名稱,例如「device_logcat」。注意:dataName 在每次呼叫時可能不具唯一性,也就是說,實作者必須能夠處理具有相同 dataName 的多項呼叫。

dataType LogDataType:資料的 LogDataType

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

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

testRunEnded

public void testRunEnded (long elapsedTime, 
                HashMap<String, MetricMeasurement.Metric> metrics)

覆寫父項,明確列印指標。

參數
elapsedTime long:裝置回報的經過時間 (以毫秒為單位)

metrics HashMap:在測試執行結束時,使用 Metric 報告的鍵/值組合。