基礎後處理器
public abstract class BasePostProcessor
extends Object
implements IPostProcessor
java.lang.Object | |
↳ | com.android.tradefed.postprocessor.BasePostProcessor |
每個實現都應該擴展的基本IPostProcessor
。確保在最終結果報告器之前調用後處理方法。
概括
公共構造函數 | |
---|---|
BasePostProcessor () |
公共方法 | |
---|---|
final ITestInvocationListener | init ( ITestInvocationListener listener) 後處理器的初始化步驟。 |
final void | invocationEnded (long elapsedTime) 報告調用已終止,無論是成功還是由於某些錯誤情況。 |
final void | invocationFailed ( FailureDescription failure) 由於某些錯誤情況而報告不完整的調用。 |
final void | invocationFailed (Throwable cause) 由於某些錯誤情況而報告不完整的調用。 |
final void | invocationStarted ( IInvocationContext context) 調用轉發監聽器 |
final boolean | isDisabled () 如果整個對像被禁用(跳過設置和拆卸),則返回 True。 |
final void | logAssociation (String dataName, LogFile logFile) 在某些情況下,日誌必須與測試用例強關聯,但有機會這樣做就直接 更新日誌到測試的關聯。 |
processAllTestMetricsAndLogs (ListMultimap<String, MetricMeasurement.Metric> allTestMetrics, allTestLogs) processAllTestMetricsAndLogs (ListMultimap<String, MetricMeasurement.Metric> allTestMetrics, allTestLogs) 實現此方法來聚合所有測試的指標和日誌。 | |
abstract | processRunMetricsAndLogs ( rawMetrics, runLogs) processRunMetricsAndLogs ( rawMetrics, runLogs) processRunMetricsAndLogs ( rawMetrics, runLogs) 實現此方法是為了從現有指標和日誌生成一組新指標。 |
processTestMetricsAndLogs ( TestDescription testDescription, testMetrics, testLogs) processTestMetricsAndLogs ( TestDescription testDescription, testMetrics, testLogs) processTestMetricsAndLogs ( TestDescription testDescription, testMetrics, testLogs) 實現此方法以發布每個測試的流程指標和日誌。 | |
final void | setLogSaver ( ILogSaver logSaver) 設置 |
void | setUp () 在子後處理器中重寫此方法以在測試運行之前進行初始化。 |
final void | testAssumptionFailure ( TestDescription test, String trace) 當原子測試標記其假定條件為 false 時調用 |
final void | testAssumptionFailure ( TestDescription test, FailureDescription failure) 當原子測試標記其假定條件為 false 時調用 |
final void | testEnded ( TestDescription test, long endTime, testMetrics) testEnded ( TestDescription test, long endTime, testMetrics) |
final 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 | testLog (String dataName, LogDataType dataType, InputStreamSource dataStream) 使用此方法從 PostProcessor 實現記錄文件。 |
final void | testLogSaved (String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile) 保存測試日誌時調用。 |
final void | testModuleEnded () 報告模塊運行結束。 |
final void | testModuleStarted ( IInvocationContext moduleContext) 報告模塊運行的開始。 |
final void | testRunEnded (long elapsedTime, runMetrics) testRunEnded (long elapsedTime, runMetrics) 報告測試運行結束。 |
final void | testRunFailed ( FailureDescription failure) 報告測試運行由於 |
final void | testRunFailed (String errorMessage) 報告測試運行由於致命錯誤而未能完成。 |
final void | testRunStarted (String runName, int testCount, int attemptNumber) 報告測試運行的開始。 |
final void | testRunStarted (String runName, int testCount) 測試運行回調 |
final void | testRunStarted (String runName, int testCount, int attemptNumber, long startTime) 報告測試運行的開始。 |
final void | testRunStopped (long elapsedTime) 由於用戶請求,報告測試運行在完成之前停止。 |
final void | testStarted ( TestDescription test, long startTime) |
final void | testStarted ( TestDescription test) 測試用例回調 |
受保護的方法 | |
---|---|
MetricMeasurement.DataType | getMetricType () 如果需要,重寫此方法以更改指標類型。 |
String | getRunName () |
公共構造函數
基礎後處理器
public BasePostProcessor ()
公共方法
在裡面
public final ITestInvocationListener init (ITestInvocationListener listener)
後處理器的初始化步驟。確保在任何測試回調之前調用。
參數 | |
---|---|
listener | ITestInvocationListener |
退貨 | |
---|---|
ITestInvocationListener |
調用結束
public final void invocationEnded (long elapsedTime)
報告調用已終止,無論是成功還是由於某些錯誤情況。
將由 TradeFederation 框架自動調用。參數 | |
---|---|
elapsedTime | long :調用所用的時間(以毫秒為單位) |
調用失敗
public final void invocationFailed (FailureDescription failure)
由於某些錯誤情況而報告不完整的調用。
將由 TradeFederation 框架自動調用。
參數 | |
---|---|
failure | FailureDescription :描述失敗原因的FailureDescription |
調用失敗
public final void invocationFailed (Throwable cause)
由於某些錯誤情況而報告不完整的調用。
將由 TradeFederation 框架自動調用。參數 | |
---|---|
cause | Throwable :失敗的Throwable 原因 |
調用開始
public final void invocationStarted (IInvocationContext context)
調用轉發監聽器
參數 | |
---|---|
context | IInvocationContext :有關調用的信息 |
被禁用
public final boolean isDisabled ()
如果整個對像被禁用(跳過設置和拆卸),則返回 True。否則為假。
退貨 | |
---|---|
boolean |
日誌關聯
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 ,應與測試用例關聯。 |
處理所有測試指標和日誌
publicprocessAllTestMetricsAndLogs (ListMultimap<String, MetricMeasurement.Metric> allTestMetrics, allTestLogs)
實現此方法來聚合所有測試的指標和日誌。此方法得出的指標將作為運行指標報告。僅應返回新生成的指標,並具有唯一的鍵名稱(不允許與現有鍵發生衝突)。
參數 | |
---|---|
allTestMetrics | ListMultimap :一個 HashMultimap,存儲按指標名稱分組的每個測試的指標。 |
allTestLogs | TestDescription 作為鍵。 |
退貨 | |
---|---|
從所有測試指標中新生成的一組指標。 |
進程運行指標和日誌
public abstractprocessRunMetricsAndLogs ( rawMetrics, runLogs)
實現此方法是為了從現有指標和日誌生成一組新指標。僅應返回新生成的指標,並具有唯一的鍵名稱(不允許與現有鍵發生衝突)。
參數 | |
---|---|
rawMetrics | |
runLogs |
退貨 | |
---|---|
從運行指標新生成的一組指標。 |
流程測試指標和日誌
publicprocessTestMetricsAndLogs (TestDescription testDescription, testMetrics, testLogs)
實現此方法以發布每個測試的流程指標和日誌。僅應返回新生成的指標,並具有唯一的鍵名稱(不允許與現有鍵發生衝突)。
參數 | |
---|---|
testDescription | TestDescription :描述測試的 TestDescription 對象。 |
testMetrics | |
testLogs |
退貨 | |
---|---|
從測試指標新生成的一組指標。 |
設置日誌保存程序
public final void setLogSaver (ILogSaver logSaver)
設置ILogSaver
以允許實現者保存文件。
參數 | |
---|---|
logSaver | ILogSaver : ILogSaver |
設置
public void setUp ()
在子後處理器中重寫此方法以在測試運行之前進行初始化。
測試假設失敗
public final void testAssumptionFailure (TestDescription test, String trace)
當原子測試標記其假定條件為 false 時調用
參數 | |
---|---|
test | TestDescription :標識測試 |
trace | String : 失敗的堆棧跟踪 |
測試假設失敗
public final void testAssumptionFailure (TestDescription test, FailureDescription failure)
當原子測試標記其假定條件為 false 時調用
參數 | |
---|---|
test | TestDescription :標識測試 |
failure | FailureDescription :描述故障及其上下文的FailureDescription 。 |
測試結束
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 final 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 | FailureDescription :描述故障及其上下文的FailureDescription 。 |
測試失敗
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 testLog (String dataName, LogDataType dataType, InputStreamSource dataStream)
使用此方法從 PostProcessor 實現記錄文件。
參數 | |
---|---|
dataName | String :數據的String 描述性名稱。例如“device_logcat”。注意 每次調用時 dataName 可能不是唯一的。即實現者必須能夠處理具有相同 dataName 的多個調用 |
dataType | LogDataType :數據的LogDataType |
dataStream | InputStreamSource :數據的InputStreamSource 。實現者應該調用 createInputStream 來開始讀取數據,並確保完成後關閉生成的 InputStream。調用者應確保數據源保持存在且可訪問,直到 testLog 方法完成。 |
測試日誌已保存
public final 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 final void testModuleEnded ()
報告模塊運行結束。
測試模塊啟動
public final void testModuleStarted (IInvocationContext moduleContext)
報告模塊運行的開始。此回調與testModuleEnded()
關聯,並且在序列中是可選的。它僅在使用模塊的運行期間使用:基於套件的運行器。
參數 | |
---|---|
moduleContext | IInvocationContext :模塊的IInvocationContext 。 |
測試運行結束
public final void testRunEnded (long elapsedTime,runMetrics)
報告測試運行結束。 FIXME:我們不能有兩個不同類型的 Map<> 接口,所以我們必須在這裡使用 HashMap。
參數 | |
---|---|
elapsedTime | long :設備報告的經過時間,以毫秒為單位 |
runMetrics | Metric 測試運行結束時報告的鍵值對。 |
測試運行失敗
public final void testRunFailed (FailureDescription failure)
報告測試運行由於FailureDescription
描述的故障而未能完成。
參數 | |
---|---|
failure | FailureDescription :描述故障及其上下文的FailureDescription 。 |
測試運行失敗
public final void testRunFailed (String errorMessage)
報告測試運行由於致命錯誤而未能完成。
參數 | |
---|---|
errorMessage | String :描述運行失敗原因的String 。 |
測試運行開始
public final void testRunStarted (String runName, int testCount, int attemptNumber)
報告測試運行的開始。
參數 | |
---|---|
runName | String : 測試運行名稱 |
testCount | int : 測試運行中的測試總數 |
attemptNumber | int :訂單號,標識同一 runName 多次運行的不同嘗試。 attemptsNumber 是從 0 開始索引的,並且每次新的運行發生時都應該遞增。例如,一個測試被粒度重試 3 次,它應該在同一 runName 下總共運行 4 次,並且 attemptsNumber 從 0 到 3。 |
測試運行開始
public final void testRunStarted (String runName, int testCount)
測試運行回調
參數 | |
---|---|
runName | String : 測試運行名稱 |
testCount | int : 測試運行中的測試總數 |
測試運行開始
public final void testRunStarted (String runName, int testCount, int attemptNumber, long startTime)
報告測試運行的開始。
參數 | |
---|---|
runName | String : 測試運行名稱 |
testCount | int : 測試運行中的測試總數 |
attemptNumber | int :訂單號,標識同一 runName 多次運行的不同嘗試。 attemptsNumber 是從 0 開始索引的,並且每次新的運行發生時都應該遞增。例如,一個測試被粒度重試 3 次,它應該在同一 runName 下總共運行 4 次,並且 attemptsNumber 從 0 到 3。 |
startTime | long :運行開始的時間,通過System.currentTimeMillis() 測量 |
測試運行停止
public final void testRunStopped (long elapsedTime)
由於用戶請求,報告測試運行在完成之前停止。
TODO:當前未使用,考慮刪除
參數 | |
---|---|
elapsedTime | long :設備報告的經過時間,以毫秒為單位 |
測試開始
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() 測量 |
受保護的方法
獲取指標類型
protected MetricMeasurement.DataType getMetricType ()
如果需要,重寫此方法以更改指標類型。默認情況下,指標設置為已處理類型。
退貨 | |
---|---|
MetricMeasurement.DataType |
獲取運行名稱
protected String getRunName ()
退貨 | |
---|---|
String |