ProtoResultReporter

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

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


結果回報器會建構 TestRecord protobuf,其中包含所有結果。應擴充以處理如何處理 processFinalProto(com.android.tradefed.result.proto.TestRecordProto.TestRecord) 中的最終 Proto。

摘要

公用建構函式

ProtoResultReporter()

公用方法

final void invocationEnded(long elapsedTime)

回報叫用已終止,無論是成功或因某些錯誤條件而終止。

void invocationFailed(FailureDescription failure)

由於某些錯誤情況,系統會回報未完成的叫用作業。

void invocationFailed(Throwable cause)

由於某些錯誤情況,系統會回報未完成的叫用作業。

void invocationSkipped(SkipReason reason)

將叫用動作回報為略過

void invocationStarted(IInvocationContext context)

回報測試叫用作業的開始時間。

final void logAssociation(String dataName, LogFile logFile)

在某些情況下,記錄必須與測試案例建立強烈關聯,但無法直接在 testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile) 回呼上執行這項操作。

void processFinalInvocationLogs(TestRecordProto.TestRecord invocationLogs)

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

void processFinalProto(TestRecordProto.TestRecord finalRecord)

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

void processStartInvocation(TestRecordProto.TestRecord invocationStartRecord, IInvocationContext invocationContext)

invocationStarted(com.android.tradefed.invoker.IInvocationContext) 發生後,處理部分叫用測試記錄的 proto。

void processTestCaseEnded(TestRecordProto.TestRecord testCaseRecord)

在發生 ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,HashMap)) 後,處理已定案的測試案例記錄 proto。

void processTestCaseStarted(TestRecordProto.TestRecord testCaseStartedRecord)

在發生 testStarted(com.android.tradefed.result.TestDescription, long) 後,處理部分測試案例記錄的 proto。

void processTestModuleEnd(TestRecordProto.TestRecord moduleRecord)

在發生 testModuleEnded() 後,處理已定義的模組記錄 proto。

void processTestModuleStarted(TestRecordProto.TestRecord moduleStartRecord)

在發生 testModuleStarted(com.android.tradefed.invoker.IInvocationContext) 後,處理部分模組記錄 proto。

void processTestRunEnded(TestRecordProto.TestRecord runRecord, boolean moduleInProgress)

ERROR(/#testRunEnded(long,HashMap)) 發生後,處理已定案的執行記錄 proto。

void processTestRunStarted(TestRecordProto.TestRecord runStartedRecord)

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

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

如果回報器支援精細結果,則傳回「是」;否則傳回「否」。

final void testAssumptionFailure(TestDescription test, String trace)

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

final void testAssumptionFailure(TestDescription test, FailureDescription failure)

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

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

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

void testEnded(TestDescription test, 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, runMetrics)

回報測試執行結束。

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)

當測試遭到略過,且未因通常預期的原因而執行時,系統會呼叫此方法。

final void testStarted(TestDescription test, long startTime)

testStarted(com.android.tradefed.result.TestDescription) 的替代方案,我們也會指定測試開始時間,並搭配 ERROR(/#testEnded(com.android.tradefed.result.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 Throwable:失敗的 Throwable 原因

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, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.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(com.android.tradefed.invoker.IInvocationContext) 後,處理部分叫用測試記錄 proto。

參數
invocationStartRecord TestRecordProto.TestRecord:在叫用開始後填入的部分 Proto。

invocationContext IInvocationContext:叫用 IInvocationContext

processTestCaseEnded

public void processTestCaseEnded (TestRecordProto.TestRecord testCaseRecord)

發生 ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,HashMap)) 後,處理已定案的測試案例記錄 proto。

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

processTestCaseStarted

public void processTestCaseStarted (TestRecordProto.TestRecord testCaseStartedRecord)

發生 testStarted(com.android.tradefed.result.TestDescription, long) 後,處理部分測試案例記錄 proto。

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

processTestModuleEnd

public void processTestModuleEnd (TestRecordProto.TestRecord moduleRecord)

發生 testModuleEnded() 後,處理已定義的模組記錄 proto。

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

processTestModuleStarted

public void processTestModuleStarted (TestRecordProto.TestRecord moduleStartRecord)

在發生 testModuleStarted(com.android.tradefed.invoker.IInvocationContext) 後,處理部分模組記錄 proto。

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

processTestRunEnded

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

ERROR(/#testRunEnded(long,HashMap)) 發生後,處理已定案的執行記錄 proto。

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

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

processTestRunStarted

public void processTestRunStarted (TestRecordProto.TestRecord runStartedRecord)

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

參數
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 FailureDescriptionFailureDescription 可說明失敗和相關情境。

testEnded

public final 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)

testEnded

public void testEnded (TestDescription test, 
                 testMetrics)

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

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

參數
test TestDescription:用於識別測試

testMetrics :傳送指標的 ERROR(/Map)

testFailed

public final void testFailed (TestDescription test, 
                FailureDescription failure)

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

會在 testStarted 和 testEnded 之間呼叫。

參數
test TestDescription:用於識別測試

failure FailureDescriptionFailureDescription 可說明失敗和相關情境。

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, 
                 runMetrics)

回報測試執行結束。

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

runMetrics :測試執行結束時回報的鍵/值組合

testRunFailed

public final void testRunFailed (FailureDescription failure)

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

參數
failure FailureDescriptionFailureDescription 可說明失敗和相關情境。

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)

當測試遭到略過,且未因通常預期的原因而執行時,系統會呼叫此方法。系統會嘗試重試這些測試,以便取得正確的執行結果。

參數
test TestDescription:用於識別測試

reason SkipReasonSkipReason

testStarted

public final 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() 測量

testStarted

public final void testStarted (TestDescription test)

回報個別測試案例的開始時間。較舊的介面,應盡可能使用 testStarted(com.android.tradefed.result.TestDescription)

參數
test TestDescription:用於識別測試

受保護的方法

afterModuleEnd

protected void afterModuleEnd ()

beforeModuleStart

protected void beforeModuleStart ()

createModuleChildReference

protected TestRecordProto.ChildReference createModuleChildReference (TestRecordProto.TestRecord record)

為模組建立子項參照。

參數
record TestRecordProto.TestRecord

傳回
TestRecordProto.ChildReference