ProtoResultReporter

public abstract class ProtoResultReporter
extends Object implements ILogSaverListener, ISupportGranularResults, ITestInvocationListener

java.lang.Object
   ↳ com.android.tradefed.result.proto.ProtoResultReporter


結果回報器會建構 TestRecord protobuf,內含所有結果。應擴充為處理 processFinalProto(TestRecord) 中的最終原型。

摘要

公用建構函式

ProtoResultReporter()

公用方法

final 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.

final void logAssociation(String dataName, LogFile logFile)

在某些情況下,記錄必須與測試案例密切相關,但無法在直接 testLogSaved(String,LogDataType,InputStreamSource,LogFile) 回呼中執行這項操作。

void processFinalInvocationLogs(TestRecordProto.TestRecord invocationLogs)

使用叫用記錄逐一傳送叫用的所有最終記錄。

void processFinalProto(TestRecordProto.TestRecord finalRecord)

處理包含所有結果的最終 Proto。

void processStartInvocation(TestRecordProto.TestRecord invocationStartRecord, IInvocationContext invocationContext)

invocationStarted(IInvocationContext) 發生後,處理部分叫用檢測記錄 Proto。

void processTestCaseEnded(TestRecordProto.TestRecord testCaseRecord)

testEnded(TestDescription,long,HashMap) 發生後,處理最終測試案例記錄原型。

void processTestCaseStarted(TestRecordProto.TestRecord testCaseStartedRecord)

處理 testStarted(TestDescription,long) 後的部分測試案例記錄原型。

void processTestModuleEnd(TestRecordProto.TestRecord moduleRecord)

testModuleEnded() 發生後,處理最終的模組記錄 Proto。

void processTestModuleStarted(TestRecordProto.TestRecord moduleStartRecord)

處理 testModuleStarted(IInvocationContext) 發生後的模組記錄部分原型。

void processTestRunEnded(TestRecordProto.TestRecord runRecord, boolean moduleInProgress)

testRunEnded(long,HashMap) 發生後,處理最終的執行記錄原型。

void processTestRunStarted(TestRecordProto.TestRecord runStartedRecord)

testRunStarted(String,int) 發生後處理部分測試執行記錄原型。

void setGranularResults(boolean granularResults)
void setInlineRecordOfChildren(boolean inline)
boolean supportGranularResults()

如果檢舉者支援精細結果,則傳回 True,否則傳回 False。

final void testAssumptionFailure(TestDescription test, String trace)

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

final void testAssumptionFailure(TestDescription test, FailureDescription failure)

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

final void testEnded(TestDescription test, long endTime, HashMap<String, MetricMeasurement.Metric> testMetrics)

testEnded(TestDescription,Map) 的替代方案,可直接指定結束時間。

void testEnded(TestDescription test, HashMap<String, MetricMeasurement.Metric> testMetrics)

回報個別測試案例的執行結束時間。

final void testFailed(TestDescription test, FailureDescription failure)

回報個別測試案例的失敗情形。

final void testFailed(TestDescription test, String trace)

回報個別測試案例的失敗情形。

final void testIgnored(TestDescription test)

當測試不會執行時呼叫,通常是因為測試方法以 org.junit.Ignore 註解標註。

final void testModuleEnded()

回報模組執行作業的結束時間。

final void testModuleStarted(IInvocationContext moduleContext)

回報模組的執行開始時間。

final void testRunEnded(long elapsedTimeMillis, HashMap<String, MetricMeasurement.Metric> runMetrics)

Reports end of test run.

final void testRunFailed(FailureDescription failure)

由於 FailureDescription 所述的錯誤,報表測試執行作業無法完成。

final void testRunFailed(String errorMessage)

發生嚴重錯誤,因此無法完成報表測試執行。

void testRunStarted(String runName, int testCount, int attemptNumber)

回報測試執行的開始。

final void testRunStarted(String runName, int testCount)

回報測試執行的開始。

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

回報測試執行的開始。

final void testSkipped(TestDescription test, SkipReason reason)

Called when a test is skipped and did not execute for a reason that is not usually expected.

final void testStarted(TestDescription test, long startTime)

testStarted(TestDescription) 的替代方案,我們也會指定測試開始時間,並搭配 testEnded(TestDescription,long,Map) 進行準確的評估。

final void testStarted(TestDescription test)

回報個別測試案例的開始時間。

受保護的方法

void afterModuleEnd()
void beforeModuleStart()
TestRecordProto.ChildReference createModuleChildReference(TestRecordProto.TestRecord record)

為模組建立子參照。

公用建構函式

ProtoResultReporter

public ProtoResultReporter ()

公用方法

invocationEnded

public final 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 ThrowableThrowable 失敗的原因

invocationSkipped

public void invocationSkipped (SkipReason reason)

將叫用回報為已略過

參數
reason SkipReason

invocationStarted

public void invocationStarted (IInvocationContext context)

回報測試呼叫的開始時間。

TradeFederation 架構會自動呼叫這個方法。檢舉者需要覆寫這個方法,才能支援多部裝置回報。

參數
context IInvocationContext:叫用相關資訊

logAssociation

public final void logAssociation (String dataName, 
                LogFile logFile)

在某些情況下,記錄必須與測試案例密切相關,但無法在直接 testLogSaved(String,LogDataType,InputStreamSource,LogFile) 回呼中執行此操作。因此,這個回呼可明確提供強關聯。

參數
dataName String:資料名稱

logFile LogFile:先前記錄的 LogFile,應與測試案例建立關聯。

processFinalInvocationLogs

public void processFinalInvocationLogs (TestRecordProto.TestRecord invocationLogs)

使用叫用記錄逐一傳送叫用的所有最終記錄。

參數
invocationLogs TestRecordProto.TestRecord:代表呼叫的最終 proto。

processFinalProto

public void processFinalProto (TestRecordProto.TestRecord finalRecord)

處理包含所有結果的最終 Proto。

參數
finalRecord TestRecordProto.TestRecord:包含所有叫用結果的最終 proto。

processStartInvocation

public void processStartInvocation (TestRecordProto.TestRecord invocationStartRecord, 
                IInvocationContext invocationContext)

invocationStarted(IInvocationContext) 發生後處理部分叫用測試記錄原型。

參數
invocationStartRecord TestRecordProto.TestRecord:在 invocationStart 後填入的部分 proto。

invocationContext IInvocationContext:叫用 IInvocationContext

processTestCaseEnded

public void processTestCaseEnded (TestRecordProto.TestRecord testCaseRecord)

testEnded(TestDescription,long,HashMap) 發生後,處理最終測試案例記錄原型。

參數
testCaseRecord TestRecordProto.TestRecord:代表測試案例的最終 proto。

processTestCaseStarted

public void processTestCaseStarted (TestRecordProto.TestRecord testCaseStartedRecord)

testStarted(TestDescription,long) 發生後,處理部分測試案例記錄原型。

參數
testCaseStartedRecord TestRecordProto.TestRecord:代表測試案例的部分 proto。

processTestModuleEnd

public void processTestModuleEnd (TestRecordProto.TestRecord moduleRecord)

testModuleEnded() 發生後,處理最終的模組記錄原型。

參數
moduleRecord TestRecordProto.TestRecord:代表模組的最終 proto。

processTestModuleStarted

public void processTestModuleStarted (TestRecordProto.TestRecord moduleStartRecord)

testModuleStarted(IInvocationContext) 發生後處理部分模組記錄原型。

參數
moduleStartRecord TestRecordProto.TestRecord:代表模組的部分 proto。

processTestRunEnded

public void processTestRunEnded (TestRecordProto.TestRecord runRecord, 
                boolean moduleInProgress)

testRunEnded(long,HashMap) 發生後,處理最終的執行記錄原型。

參數
runRecord TestRecordProto.TestRecord:代表執行的最終 proto。

moduleInProgress boolean:模組是否正在進行中。

processTestRunStarted

public void processTestRunStarted (TestRecordProto.TestRecord runStartedRecord)

testRunStarted(String,int) 之後處理部分測試執行記錄原型。

參數
runStartedRecord TestRecordProto.TestRecord:代表執行的部分 proto。

setGranularResults

public void setGranularResults (boolean granularResults)

參數
granularResults boolean

setInlineRecordOfChildren

public void setInlineRecordOfChildren (boolean inline)

參數
inline boolean

supportGranularResults

public boolean supportGranularResults ()

如果檢舉者支援精細結果,則傳回 True,否則傳回 False。

傳回
boolean

testAssumptionFailure

public final void testAssumptionFailure (TestDescription test, 
                String trace)

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

參數
test TestDescription:識別測試

trace String:失敗的堆疊追蹤

testAssumptionFailure

public final void testAssumptionFailure (TestDescription test, 
                FailureDescription failure)

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

參數
test TestDescription:識別測試

failure FailureDescription:說明失敗情形和相關情境的 FailureDescription

testEnded

public final void testEnded (TestDescription test, 
                long endTime, 
                HashMap<String, MetricMeasurement.Metric> testMetrics)

testEnded(TestDescription,Map) 的替代方案,可直接指定結束時間。搭配 testStarted(TestDescription,long) 使用,可準確測量。

參數
test TestDescription:識別測試

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

testMetrics HashMap:發出的指標 Map

testEnded

public void testEnded (TestDescription test, 
                HashMap<String, MetricMeasurement.Metric> testMetrics)

回報個別測試案例的執行結束時間。

如果未叫用 testFailed(TestDescription, FailureDescription),這項測試就會通過。也會傳回測試案例執行期間可能發出的任何鍵/值指標。

參數
test TestDescription:識別測試

testMetrics HashMap:發出的指標 Map

testFailed

public final void testFailed (TestDescription test, 
                FailureDescription failure)

回報個別測試案例的失敗情形。

會在 testStarted 和 testEnded 之間呼叫。

參數
test TestDescription:識別測試

failure FailureDescription:說明失敗情形和相關情境的 FailureDescription

testFailed

public final void testFailed (TestDescription test, 
                String trace)

回報個別測試案例的失敗情形。

會在 testStarted 和 testEnded 之間呼叫。

參數
test TestDescription:識別測試

trace String:失敗的堆疊追蹤

testIgnored

public final void testIgnored (TestDescription test)

當測試不會執行時呼叫,通常是因為測試方法以 org.junit.Ignore 註解標註。

參數
test TestDescription:識別測試

testModuleEnded

public final void testModuleEnded ()

回報模組執行作業的結束時間。

testModuleStarted

public final void testModuleStarted (IInvocationContext moduleContext)

回報模組的執行開始時間。這個回呼與 testModuleEnded() 相關聯,且在序列中為選用項目。只有在使用模組的執行期間,才會使用這個標記:以套件為基礎的執行器。

參數
moduleContext IInvocationContext:模組的 IInvocationContext

testRunEnded

public final void testRunEnded (long elapsedTimeMillis, 
                HashMap<String, MetricMeasurement.Metric> runMetrics)

測試執行結束時會回報。FIXME:我們無法使用不同型別的兩個 Map<> 介面,因此必須在此使用 HashMap。

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

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

testRunFailed

public final void testRunFailed (FailureDescription failure)

由於 FailureDescription 所述的錯誤,報表測試執行作業無法完成。

參數
failure FailureDescription:說明失敗情形和相關情境的 FailureDescription

testRunFailed

public final void testRunFailed (String errorMessage)

發生嚴重錯誤,因此無法完成報表測試執行作業。

參數
errorMessage StringString,說明執行失敗的原因。

testRunStarted

public void testRunStarted (String runName, 
                int testCount, 
                int attemptNumber)

回報測試執行的開始時間。

參數
runName String:測試執行名稱

testCount int:測試執行作業中的測試總數

attemptNumber int:訂單號碼,用於識別多次執行的相同 runName 的不同嘗試。attemptNumber 是以 0 為索引,每次執行新作業時都應遞增。舉例來說,如果測試精細重試 3 次,則在相同 runName 下應有 4 次執行作業,且 attemptNumber 為 0 到 3。

testRunStarted

public final void testRunStarted (String runName, 
                int testCount)

回報測試執行的開始時間。

參數
runName String:測試執行名稱

testCount int:測試執行作業中的測試總數

testRunStarted

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

回報測試執行的開始時間。

參數
runName String:測試執行名稱

testCount int:測試執行作業中的測試總數

attemptNumber int:訂單號碼,用於識別多次執行的相同 runName 的不同嘗試。attemptNumber 是以 0 為索引,每次執行新作業時都應遞增。舉例來說,如果測試精細重試 3 次,則在相同 runName 下應有 4 次執行,且 attemptNumber 為 0 到 3。

startTime long:跑步開始時間,透過 System.currentTimeMillis() 測量

testSkipped

public final void testSkipped (TestDescription test, 
                SkipReason reason)

Called when a test is skipped and did not execute for a reason that is not usually expected. 系統會嘗試重試這些測試,以確保正常執行。

參數
test TestDescription:識別測試

reason SkipReasonSkipReason

testStarted

public final void testStarted (TestDescription test, 
                long startTime)

testStarted(TestDescription) 的替代方案,我們也會指定測試開始時間,並搭配 testEnded(TestDescription,long,Map) 進行準確的評估。

參數
test TestDescription:識別測試

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

testStarted

public final void testStarted (TestDescription test)

回報個別測試案例的開始時間。舊版介面,建議盡可能使用 testStarted(TestDescription)

參數
test TestDescription:識別測試

受保護的方法

afterModuleEnd

protected void afterModuleEnd ()

beforeModuleStart

protected void beforeModuleStart ()

createModuleChildReference

protected TestRecordProto.ChildReference createModuleChildReference (TestRecordProto.TestRecord record)

為模組建立子項參照。

參數
record TestRecordProto.TestRecord

傳回
TestRecordProto.ChildReference