收集測試監聽器

public class CollectingTestListener
extends Object implements ITestInvocationListener, ILogSaverListener

java.lang.Object
com.android.tradefed.result.CollectingTestListener


將收集所有測試結果的ITestInvocationListener

儘管此物件中使用的資料結構是線程安全的,但必須以正確的順序呼叫ITestInvocationListener回呼。

概括

公共構造函數

CollectingTestListener ()

公共方法

IBuildInfo getBuildInfo ()

此方法已被棄用。依賴getInvocationContext()中的IBuildInfo

TestRunResult getCurrentRunResults ()

取得目前測試運行的結果。

int getExpectedTests ()

傳回預期測試計數的數量。

IInvocationContext getInvocationContext ()

傳回透過invocationStarted(com.android.tradefed.invoker.IInvocationContext)報告的呼叫上下文

getMergedTestRunResults ()

傳回不同嘗試中所有運行的合併結果集合。

IInvocationContext getModuleContextForRunResult (String testRunName)

傳回與結果關聯的模組的IInvocationContext

MultiMap<String, LogFile> getModuleLogFiles ()

傳回包含與模組關聯的所有記錄檔案的對應副本

MultiMap<String, LogFile> getNonAssociatedLogFiles ()

傳回映射的副本,其中包含與測試運行或模組無關的所有記錄檔案。

int getNumAllFailedTestRuns ()

傳回處於失敗狀態的測試運行總數

int getNumAllFailedTests ()

傳回處於失敗狀態的測試總數(僅失敗,假設失敗不計入)。

int getNumTestsInState (TestResult.TestStatus status)

傳回本次運行的給定狀態下的測試數量。

int getNumTotalTests ()

傳回所有運行的完整測試總數。

IBuildInfo getPrimaryBuildInfo ()

傳回透過invocationStarted(com.android.tradefed.invoker.IInvocationContext)報告的主要建置資訊。

getRunResults ()

此方法已被棄用。使用getMergedTestRunResults()

TestRunResult getTestRunAtAttempt (String testRunName, int attempt)

傳回單次嘗試的TestRunResult

int getTestRunAttemptCount (String testRunName)

傳回給定測試運行名稱的嘗試次數。

getTestRunAttempts (String testRunName)

取得給定測試運行的TestRunResult的所有嘗試。

getTestRunForAttempts (int attempt)

取得給定嘗試的所有結果。

getTestRunNames ()

傳回所有測試運行的所有名稱。

boolean hasFailedTests ()

如果呼叫有任何失敗或假設失敗的測試,則傳回。

boolean hasTestRunResultsForName (String testRunName)

傳回給定的測試運行名稱是否有任何結果。

void invocationEnded (long elapsedTime)

void invocationFailed (Throwable cause)

void invocationStarted (IInvocationContext context)

void logAssociation (String dataName, LogFile logFile)

void setBuildInfo (IBuildInfo buildInfo)

此方法已被棄用。不再需要進行測試。

void setMergeStrategy (MergeStrategy strategy)

設定合併結果時要使用的MergeStrategy

void testAssumptionFailure (TestDescription test, String trace)
void testAssumptionFailure (TestDescription test, FailureDescription failure)
void testEnded (TestDescription test, long endTime, testMetrics) testEnded (TestDescription test, long endTime, testMetrics)

void testEnded (TestDescription test, testMetrics) testEnded (TestDescription test, testMetrics)

void testFailed (TestDescription test, FailureDescription failure)
void testFailed (TestDescription test, String trace)

void testIgnored (TestDescription test)
void testModuleEnded ()
void testModuleStarted (IInvocationContext moduleContext)
void testRunEnded (long elapsedTime, runMetrics) testRunEnded (long elapsedTime, runMetrics)

void testRunFailed (FailureDescription failure)

void testRunFailed (String errorMessage)

void testRunStarted (String name, int numTests, int attemptNumber)

void testRunStarted (String name, int numTests)

void testRunStarted (String name, int numTests, int attemptNumber, long startTime)

void testRunStopped (long elapsedTime)

void testStarted (TestDescription test, long startTime)

void testStarted (TestDescription test)

受保護的方法

final void clearModuleLogFiles ()

允許清理模組文件,這樣我們就可以避免攜帶它們太久。

final void clearResultsForName (String testRunName)

允許清除給定運行名稱的結果。

void setIsAggregrateMetrics (boolean aggregate)

切換“聚合指標”選項

公共構造函數

收集測試監聽器

public CollectingTestListener ()

公共方法

獲取建構資訊

public IBuildInfo getBuildInfo ()

此方法已被棄用。
依賴getInvocationContext()中的IBuildInfo

返回建置資訊。

退貨
IBuildInfo

取得目前運行結果

public TestRunResult getCurrentRunResults ()

取得目前測試運行的結果。

請注意,結果可能不完整。建議在處理結果之前根據需要測試TestRunResult.isRunComplete()和/或 (@link TestRunResult#isRunFailure()} 的值。

退貨
TestRunResult TestRunResult表示上次測試運行期間收集的數據

取得預期測試

public int getExpectedTests ()

傳回預期測試計數的數量。如果某些測試未運行,則可能與getNumTotalTests()不同。

退貨
int

取得呼叫上下文

public IInvocationContext getInvocationContext ()

傳回透過invocationStarted(com.android.tradefed.invoker.IInvocationContext)報告的呼叫上下文

退貨
IInvocationContext

取得合併測試運行結果

public  getMergedTestRunResults ()

傳回不同嘗試中所有運行的合併結果集合。

如果有多個結果,則每次測試運行都會合併,最新的測試結果會覆蓋先前執行的測試結果。測試運行按嘗試次數排序。

同一嘗試的指標將根據aggregate-metrics設定的首選項進行合併。最終指標將是最後一次嘗試的指標。

退貨

getModuleContextForRunResult

public IInvocationContext getModuleContextForRunResult (String testRunName)

傳回與結果關聯的模組的IInvocationContext

參數
testRunName String :由 { testRunStarted(String, int)給出的名稱。

退貨
IInvocationContext如果給定測試運行名稱沒有結果,則該模組的IInvocationContext null

取得模組日誌文件

public MultiMap<String, LogFile> getModuleLogFiles ()

傳回包含與模組關聯的所有記錄檔案的對應副本

退貨
MultiMap<String, LogFile>

取得非關聯日誌文件

public MultiMap<String, LogFile> getNonAssociatedLogFiles ()

傳回映射的副本,其中包含與測試運行或模組無關的所有記錄檔案。

退貨
MultiMap<String, LogFile>

getNumAllFailedTestRuns

public int getNumAllFailedTestRuns ()

傳回處於失敗狀態的測試運行總數

退貨
int

取得所有失敗測試數

public int getNumAllFailedTests ()

傳回處於失敗狀態的測試總數(僅失敗,假設失敗不計入)。

退貨
int

取得狀態測試數

public int getNumTestsInState (TestResult.TestStatus status)

傳回本次運行的給定狀態下的測試數量。

參數
status TestResult.TestStatus

退貨
int

取得測試總數

public int getNumTotalTests ()

傳回所有運行的完整測試總數。

退貨
int

獲取主要構建信息

public IBuildInfo getPrimaryBuildInfo ()

傳回透過invocationStarted(com.android.tradefed.invoker.IInvocationContext)報告的主要建置資訊。主要建置是由運行配置的第一個建置提供者傳回的建置。如果沒有上下文(沒有建置測試案例),則傳回 null。

退貨
IBuildInfo

取得運行結果

public  getRunResults ()

此方法已被棄用。
使用getMergedTestRunResults()

傳回所有測試運行的結果。

退貨

取得測試運行嘗試

public TestRunResult getTestRunAtAttempt (String testRunName, 
                int attempt)

傳回單次嘗試的TestRunResult

參數
testRunName String :由 { testRunStarted(String, int)給出的名稱。

attempt int :嘗試 ID。

退貨
TestRunResult給定名稱和嘗試 ID 的TestRunResultnull (如果不存在)。

取得測試運行嘗試計數

public int getTestRunAttemptCount (String testRunName)

傳回給定測試運行名稱的嘗試次數。

參數
testRunName String :由 { testRunStarted(String, int)給出的名稱。

退貨
int

取得測試運行嘗試

public  getTestRunAttempts (String testRunName)

取得給定測試運行的TestRunResult的所有嘗試。

參數
testRunName String :由 { testRunStarted(String, int)給出的名稱。

退貨
給定測試運行的所有TestRunResult ,按嘗試排序。

取得測試運行嘗試

public  getTestRunForAttempts (int attempt)

取得給定嘗試的所有結果。

參數
attempt int :我們想要結果的嘗試。

退貨
給定嘗試的所有TestRunResult

取得測試運行名稱

public  getTestRunNames ()

傳回所有測試運行的所有名稱。

這些測試運行可能會以不同的嘗試運行多次。

退貨

測試失敗

public boolean hasFailedTests ()

如果呼叫有任何失敗或假設失敗的測試,則傳回。

退貨
boolean

hasTestRunResultsForName

public boolean hasTestRunResultsForName (String testRunName)

傳回給定的測試運行名稱是否有任何結果。

參數
testRunName String :由 { testRunStarted(String, int)給出的名稱。

退貨
boolean

呼叫結束

public void invocationEnded (long elapsedTime)

參數
elapsedTime long

呼叫失敗

public void invocationFailed (Throwable cause)

參數
cause Throwable

調用開始

public void invocationStarted (IInvocationContext context)

參數
context IInvocationContext

日誌關聯

public void logAssociation (String dataName, 
                LogFile logFile)

參數
dataName String

logFile LogFile

設定建置資訊

public void setBuildInfo (IBuildInfo buildInfo)

此方法已被棄用。
不再需要進行測試。

設定建置資訊。應該僅用於測試。

參數
buildInfo IBuildInfo

設定合併策略

public void setMergeStrategy (MergeStrategy strategy)

設定合併結果時要使用的MergeStrategy

參數
strategy MergeStrategy

測試假設失敗

public void testAssumptionFailure (TestDescription test, 
                String trace)

參數
test TestDescription

trace String

測試假設失敗

public void testAssumptionFailure (TestDescription test, 
                FailureDescription failure)

參數
test TestDescription

failure FailureDescription

測試結束

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

參數
test TestDescription

endTime long

testMetrics

測試結束

public void testEnded (TestDescription test, 
                 testMetrics)

參數
test TestDescription

testMetrics

測試失敗

public void testFailed (TestDescription test, 
                FailureDescription failure)

參數
test TestDescription

failure FailureDescription

測試失敗

public void testFailed (TestDescription test, 
                String trace)

參數
test TestDescription

trace String

測試被忽略

public void testIgnored (TestDescription test)

參數
test TestDescription

測試模組結束

public void testModuleEnded ()

測試模組啟動

public void testModuleStarted (IInvocationContext moduleContext)

參數
moduleContext IInvocationContext

測試運行結束

public void testRunEnded (long elapsedTime, 
                 runMetrics)

參數
elapsedTime long

runMetrics

測試運行失敗

public void testRunFailed (FailureDescription failure)

參數
failure FailureDescription

測試運行失敗

public void testRunFailed (String errorMessage)

參數
errorMessage String

測試運行開始

public void testRunStarted (String name, 
                int numTests, 
                int attemptNumber)

參數
name String

numTests int

attemptNumber int

測試運行開始

public void testRunStarted (String name, 
                int numTests)

參數
name String

numTests int

測試運行開始

public void testRunStarted (String name, 
                int numTests, 
                int attemptNumber, 
                long startTime)

參數
name String

numTests int

attemptNumber int

startTime long

測試運行停止

public void testRunStopped (long elapsedTime)

參數
elapsedTime long

測試開始

public void testStarted (TestDescription test, 
                long startTime)

參數
test TestDescription

startTime long

測試開始

public void testStarted (TestDescription test)

參數
test TestDescription

受保護的方法

清除模組日誌文件

protected final void clearModuleLogFiles ()

允許清理模組文件,這樣我們就可以避免攜帶它們太久。

清除名稱結果

protected final void clearResultsForName (String testRunName)

允許清除給定運行名稱的結果。僅應在某些情況下使用,例如結果聚合器。

參數
testRunName String

setIsAggregateMetrics

protected void setIsAggregrateMetrics (boolean aggregate)

切換“聚合指標”選項

參數
aggregate boolean