ProtoResultReporter

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

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


結果報告器構建了一個包含所有結果的TestRecord protobuf。應該擴展以處理如何處理processFinalProto(com.android.tradefed.result.proto.TestRecordProto.TestRecord)中的最終原型。

概括

公共構造函數

ProtoResultReporter ()

公共方法

final void invocationEnded (long elapsedTime)

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

void invocationFailed ( FailureDescription failure)

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

void invocationFailed (Throwable cause)

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

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

處理帶有所有結果的最終原型。

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))發生後對最終測試用例記錄原型的處理。

void processTestCaseStarted (TestRecordProto.TestRecord testCaseStartedRecord)

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

void processTestModuleEnd (TestRecordProto.TestRecord moduleRecord)

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

void processTestModuleStarted (TestRecordProto.TestRecord moduleStartRecord)

testModuleStarted(com.android.tradefed.invoker.IInvocationContext)發生後處理部分模塊記錄原型。

void processTestRunEnded (TestRecordProto.TestRecord runRecord, boolean moduleInProgress)

ERROR(/#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)

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

final void testAssumptionFailure ( TestDescription test, FailureDescription failure)

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

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

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

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

報告單個測試用例的開始。

受保護的方法

TestRecordProto.ChildReference createModuleChildReference (TestRecordProto.TestRecord record)

為模塊創建子引用。

公共構造函數

ProtoResultReporter

public ProtoResultReporter ()

公共方法

調用結束

public final void invocationEnded (long elapsedTime)

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

將由 TradeFederation 框架自動調用。

參數
elapsedTime long :調用的經過時間,以毫秒為單位

調用失敗

public void invocationFailed (FailureDescription failure)

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

將由 TradeFederation 框架自動調用。

參數
failure FailureDescription : 描述失敗原因的FailureDescription

調用失敗

public void invocationFailed (Throwable cause)

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

將由 TradeFederation 框架自動調用。

參數
cause Throwable : Throwable失敗的原因

調用開始

public final void invocationStarted (IInvocationContext context)

報告測試調用的開始。

將由 TradeFederation 框架自動調用。報告者需要覆蓋此方法以支持多設備報告。

參數
context IInvocationContext :有關調用的信息

日誌關聯

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 :代表調用的最終原型。

processFinalProto

public void processFinalProto (TestRecordProto.TestRecord finalRecord)

處理帶有所有結果的最終原型。

參數
finalRecord TestRecordProto.TestRecord :包含所有調用結果的最終原型。

進程啟動調用

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

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

參數
invocationStartRecord TestRecordProto.TestRecord :invocationStart 後填充的部分原型。

invocationContext IInvocationContext :調用IInvocationContext

進程TestCaseEnded

public void processTestCaseEnded (TestRecordProto.TestRecord testCaseRecord)

ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,HashMap))發生後對最終測試用例記錄原型的處理。

參數
testCaseRecord TestRecordProto.TestRecord :代表測試用例的最終原型。

processTestCaseStarted

public void processTestCaseStarted (TestRecordProto.TestRecord testCaseStartedRecord)

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

參數
testCaseStartedRecord TestRecordProto.TestRecord :代表測試用例的部分原型。

processTestModuleEnd

public void processTestModuleEnd (TestRecordProto.TestRecord moduleRecord)

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

參數
moduleRecord TestRecordProto.TestRecord :代表模塊的最終原型。

processTestModuleStarted

public void processTestModuleStarted (TestRecordProto.TestRecord moduleStartRecord)

testModuleStarted(com.android.tradefed.invoker.IInvocationContext)發生後處理部分模塊記錄原型。

參數
moduleStartRecord TestRecordProto.TestRecord :代表模塊的部分原型。

進程測試運行結束

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

ERROR(/#testRunEnded(long,HashMap))發生後對最終運行記錄原型的處理。

參數
runRecord TestRecordProto.TestRecord :代表運行的最終原型。

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

processTestRunStarted

public void processTestRunStarted (TestRecordProto.TestRecord runStartedRecord)

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

參數
runStartedRecord TestRecordProto.TestRecord :代表運行的部分原型。

setGranularResults

public void setGranularResults (boolean granularResults)

參數
granularResults boolean

setInlineRecordOfChildren

public void setInlineRecordOfChildren (boolean inline)

參數
inline boolean

支持粒度結果

public boolean supportGranularResults ()

如果報告器支持粒度結果,則返回 True,否則返回 false。

退貨
boolean

測試假設失敗

public final void testAssumptionFailure (TestDescription test, 
                String trace)

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

參數
test TestDescription : 標識測試

trace String :失敗的堆棧跟踪

測試假設失敗

public final void testAssumptionFailure (TestDescription test, 
                FailureDescription failure)

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

參數
test TestDescription : 標識測試

failure FailureDescriptionFailureDescription描述失敗及其上下文。

測試結束

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)

測試結束

public void testEnded (TestDescription test, 
                 testMetrics)

報告單個測試用例的執行結束。

如果未調用testFailed(TestDescription, FailureDescription) ,則此測試通過。還返回在測試用例執行期間可能已發出的任何鍵/值指標。

參數
test TestDescription : 標識測試

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

測試失敗

public final void testFailed (TestDescription test, 
                FailureDescription failure)

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

將在 testStarted 和 testEnded 之間調用。

參數
test TestDescription : 標識測試

failure FailureDescriptionFailureDescription描述失敗及其上下文。

測試失敗

public final void testFailed (TestDescription test, 
                String trace)

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

將在 testStarted 和 testEnded 之間調用。

參數
test TestDescription : 標識測試

trace String :失敗的堆棧跟踪

測試忽略

public final void testIgnored (TestDescription test)

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

參數
test TestDescription : 標識測試

測試模塊結束

public final void testModuleEnded ()

報告模塊運行的結束。

testModuleStarted

public final void testModuleStarted (IInvocationContext moduleContext)

報告正在運行的模塊的開始。此回調與testModuleEnded()相關聯,並且在序列中是可選的。它僅在使用模塊的運行期間使用:基於套件的運行器。

參數
moduleContext IInvocationContext :模塊的IInvocationContext

測試運行結束

public final void testRunEnded (long elapsedTimeMillis, 
                 runMetrics)

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

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

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

測試運行失敗

public final void testRunFailed (FailureDescription failure)

由於FailureDescription描述的失敗,報告測試運行未能完成。

參數
failure FailureDescriptionFailureDescription描述失敗及其上下文。

測試運行失敗

public final void testRunFailed (String errorMessage)

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

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

測試運行開始

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

報告測試運行的開始。

參數
runName String : 測試運行名稱

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

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

測試運行開始

public final void testRunStarted (String runName, 
                int testCount)

報告測試運行的開始。

參數
runName String : 測試運行名稱

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

測試運行開始

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

報告測試運行的開始。

參數
runName String : 測試運行名稱

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

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

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

測試開始

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

測試開始

public final void testStarted (TestDescription test)

報告單個測試用例的開始。舊界面,應盡可能使用testStarted(com.android.tradefed.result.TestDescription)

參數
test TestDescription : 標識測試

受保護的方法

createModuleChildReference

protected TestRecordProto.ChildReference createModuleChildReference (TestRecordProto.TestRecord record)

為模塊創建子引用。

參數
record TestRecordProto.TestRecord

退貨
TestRecordProto.ChildReference