CollectingTestListener
public
class
CollectingTestListener
extends Object
implements
ITestInvocationListener,
ILogSaverListener
java.lang.Object | |
↳ | com.android.tradefed.result.CollectingTestListener |
用於收集所有測試結果的 ITestInvocationListener
。
雖然這個物件中使用的資料結構是執行緒安全的,但必須按照正確順序呼叫 ITestInvocationListener
回呼。
摘要
公用建構函式 | |
---|---|
CollectingTestListener()
|
公用方法 | |
---|---|
IBuildInfo
|
getBuildInfo()
這個方法已淘汰。
依賴 |
TestRunResult
|
getCurrentRunResults()
取得目前測試執行結果。 |
int
|
getExpectedTests()
傳回預期測試次數。 |
IInvocationContext
|
getInvocationContext()
傳回透過 |
|
getMergedTestRunResults()
針對不同嘗試的所有執行作業,傳回合併的結果集合。 |
IInvocationContext
|
getModuleContextForRunResult(String testRunName)
傳回與結果相關聯的模組 |
MultiMap<String, LogFile>
|
getModuleLogFiles()
傳回地圖的副本,其中包含與模組相關聯的所有記錄檔案 |
MultiMap<String, LogFile>
|
getNonAssociatedLogFiles()
傳回地圖的副本,其中包含所有未與測試執行或模組相關聯的記錄檔案。 |
int
|
getNumAllFailedTestRuns()
傳回失敗狀態的測試執行總數 |
int
|
getNumAllFailedTests()
傳回失敗狀態的測試總數 (僅限失敗,假設失敗不會計入)。 |
int
|
getNumTestsInState(TestResult.TestStatus status)
傳回此執行作業中處於指定狀態的測試數量。 |
int
|
getNumTotalTests()
傳回所有執行作業的完成測試總數。 |
IBuildInfo
|
getPrimaryBuildInfo()
傳回透過 |
|
getRunResults()
這個方法已淘汰。
使用 |
TestRunResult
|
getTestRunAtAttempt(String testRunName, int attempt)
傳回單一嘗試的 |
int
|
getTestRunAttemptCount(String testRunName)
傳回指定測試執行名稱的嘗試次數。 |
|
getTestRunAttempts(String testRunName)
取得特定測試執行作業的 |
|
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)
設定要用於合併結果的 |
void
|
testAssumptionFailure(TestDescription test, String trace)
|
void
|
testAssumptionFailure(TestDescription test, FailureDescription failure)
|
void
|
testEnded(TestDescription test, long endTime,
|
void
|
testEnded(TestDescription test,
|
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,
|
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)
切換「匯總指標」選項 |
公用建構函式
CollectingTestListener
public CollectingTestListener ()
公用方法
getBuildInfo
public IBuildInfo getBuildInfo ()
This method is deprecated.
依附於 getInvocationContext()
的 IBuildInfo
。
傳回建構資訊。
傳回 | |
---|---|
IBuildInfo |
getCurrentRunResults
public TestRunResult getCurrentRunResults ()
取得目前測試執行結果。
請注意,結果可能不完整。建議您在處理結果前,先測試 TestRunResult.isRunComplete()
的值和/或 (@link TestRunResult#isRunFailure()})。
傳回 | |
---|---|
TestRunResult |
TestRunResult 代表上次執行測試時收集的資料 |
getExpectedTests
public int getExpectedTests ()
傳回預期測試次數。如果部分測試未執行,可能會與 getNumTotalTests()
不同。
傳回 | |
---|---|
int |
getInvocationContext
public IInvocationContext getInvocationContext ()
傳回透過 invocationStarted(com.android.tradefed.invoker.IInvocationContext)
回報的叫用程序內容
傳回 | |
---|---|
IInvocationContext |
getMergedTestRunResults
publicgetMergedTestRunResults ()
針對不同嘗試次數的所有執行作業,傳回合併的結果集合。
如果有多個結果,系統會合併每項測試,最新的測試結果會覆寫先前測試的結果。測試執行作業會依嘗試次數排序。
系統會根據 aggregate-metrics
設定的偏好設定,合併相同嘗試的指標。最終指標將是上次嘗試的指標。
傳回 | |
---|---|
|
getModuleContextForRunResult
public IInvocationContext getModuleContextForRunResult (String testRunName)
傳回與結果相關聯的模組 IInvocationContext
。
參數 | |
---|---|
testRunName |
String :{testRunStarted(String, int) }提供的名稱。 |
傳回 | |
---|---|
IInvocationContext |
如果指定的測試執行名稱 null 沒有任何結果,則為該模組的 IInvocationContext 。 |
getModuleLogFiles
public MultiMap<String, LogFile> getModuleLogFiles ()
傳回地圖的副本,其中包含與模組相關聯的所有記錄檔案
傳回 | |
---|---|
MultiMap<String, LogFile> |
getNonAssociatedLogFiles
public MultiMap<String, LogFile> getNonAssociatedLogFiles ()
傳回地圖的副本,其中包含所有未與測試執行或模組相關聯的記錄檔案。
傳回 | |
---|---|
MultiMap<String, LogFile> |
getNumAllFailedTestRuns
public int getNumAllFailedTestRuns ()
傳回失敗狀態的測試執行總數
傳回 | |
---|---|
int |
getNumAllFailedTests
public int getNumAllFailedTests ()
傳回失敗狀態的測試總數 (僅限失敗的測試,假設失敗不會計入)。
傳回 | |
---|---|
int |
getNumTestsInState
public int getNumTestsInState (TestResult.TestStatus status)
傳回此執行作業中處於指定狀態的測試數量。
參數 | |
---|---|
status |
TestResult.TestStatus |
傳回 | |
---|---|
int |
getNumTotalTests
public int getNumTotalTests ()
傳回所有執行作業的完成測試總數。
傳回 | |
---|---|
int |
getPrimaryBuildInfo
public IBuildInfo getPrimaryBuildInfo ()
傳回透過 invocationStarted(com.android.tradefed.invoker.IInvocationContext)
回報的主要版本資訊。主要版本是執行設定的第一個版本提供者傳回的版本。如果沒有任何結構定義 (沒有建構至測試案例),則會傳回空值。
傳回 | |
---|---|
IBuildInfo |
getRunResults
publicgetRunResults ()
This method is deprecated.
使用 getMergedTestRunResults()
傳回所有測試執行結果。
傳回 | |
---|---|
|
getTestRunAtAttempt
public TestRunResult getTestRunAtAttempt (String testRunName, int attempt)
針對單一嘗試傳回 TestRunResult
。
參數 | |
---|---|
testRunName |
String :{testRunStarted(String, int) }提供的名稱。 |
attempt |
int :嘗試 ID。 |
傳回 | |
---|---|
TestRunResult |
指定名稱和嘗試 ID 的 TestRunResult ,如果不存在則為 null 。 |
getTestRunAttemptCount
public int getTestRunAttemptCount (String testRunName)
傳回指定測試執行名稱的嘗試次數。
參數 | |
---|---|
testRunName |
String :{testRunStarted(String, int) } 指定的名稱。 |
傳回 | |
---|---|
int |
getTestRunAttempts
publicgetTestRunAttempts (String testRunName)
取得指定測試執行作業的 TestRunResult
所有嘗試次數。
參數 | |
---|---|
testRunName |
String :{testRunStarted(String, int) }提供的名稱。 |
傳回 | |
---|---|
|
特定測試執行作業的所有 TestRunResult ,按嘗試次數排序。 |
getTestRunForAttempts
publicgetTestRunForAttempts (int attempt)
取得指定嘗試次數的所有結果。
參數 | |
---|---|
attempt |
int :我們要取得結果的嘗試次數。 |
傳回 | |
---|---|
|
指定嘗試次數的所有 TestRunResult 。 |
getTestRunNames
publicgetTestRunNames ()
傳回所有測試執行作業的所有名稱。
這些測試可能會以不同的嘗試方式執行多次。
傳回 | |
---|---|
|
hasFailedTests
public boolean hasFailedTests ()
傳回叫用是否有任何失敗或假設失敗的測試。
傳回 | |
---|---|
boolean |
hasTestRunResultsForName
public boolean hasTestRunResultsForName (String testRunName)
傳回特定測試執行名稱是否有任何結果。
參數 | |
---|---|
testRunName |
String :{testRunStarted(String, int) } 指定的名稱。 |
傳回 | |
---|---|
boolean |
invocationEnded
public void invocationEnded (long elapsedTime)
參數 | |
---|---|
elapsedTime |
long |
invocationFailed
public void invocationFailed (Throwable cause)
參數 | |
---|---|
cause |
Throwable |
invocationStarted
public void invocationStarted (IInvocationContext context)
參數 | |
---|---|
context |
IInvocationContext |
logAssociation
public void logAssociation (String dataName, LogFile logFile)
參數 | |
---|---|
dataName |
String |
logFile |
LogFile |
setBuildInfo
public void setBuildInfo (IBuildInfo buildInfo)
This method is deprecated.
測試時不再需要。
設定建構資訊。僅供測試使用。
參數 | |
---|---|
buildInfo |
IBuildInfo |
setMergeStrategy
public void setMergeStrategy (MergeStrategy strategy)
設定要用於合併結果的 MergeStrategy
。
參數 | |
---|---|
strategy |
MergeStrategy |
testAssumptionFailure
public void testAssumptionFailure (TestDescription test, String trace)
參數 | |
---|---|
test |
TestDescription |
trace |
String |
testAssumptionFailure
public void testAssumptionFailure (TestDescription test, FailureDescription failure)
參數 | |
---|---|
test |
TestDescription |
failure |
FailureDescription |
testEnded
public void testEnded (TestDescription test, long endTime,testMetrics)
參數 | |
---|---|
test |
TestDescription |
endTime |
long |
testMetrics |
|
testEnded
public void testEnded (TestDescription test,testMetrics)
參數 | |
---|---|
test |
TestDescription |
testMetrics |
|
testFailed
public void testFailed (TestDescription test, FailureDescription failure)
參數 | |
---|---|
test |
TestDescription |
failure |
FailureDescription |
testFailed
public void testFailed (TestDescription test, String trace)
參數 | |
---|---|
test |
TestDescription |
trace |
String |
testIgnored
public void testIgnored (TestDescription test)
參數 | |
---|---|
test |
TestDescription |
testModuleEnded
public void testModuleEnded ()
testModuleStarted
public void testModuleStarted (IInvocationContext moduleContext)
參數 | |
---|---|
moduleContext |
IInvocationContext |
testRunEnded
public void testRunEnded (long elapsedTime,runMetrics)
參數 | |
---|---|
elapsedTime |
long |
runMetrics |
|
testRunFailed
public void testRunFailed (FailureDescription failure)
參數 | |
---|---|
failure |
FailureDescription |
testRunFailed
public void testRunFailed (String errorMessage)
參數 | |
---|---|
errorMessage |
String |
testRunStarted
public void testRunStarted (String name, int numTests, int attemptNumber)
參數 | |
---|---|
name |
String |
numTests |
int |
attemptNumber |
int |
testRunStarted
public void testRunStarted (String name, int numTests)
參數 | |
---|---|
name |
String |
numTests |
int |
testRunStarted
public void testRunStarted (String name, int numTests, int attemptNumber, long startTime)
參數 | |
---|---|
name |
String |
numTests |
int |
attemptNumber |
int |
startTime |
long |
testRunStopped
public void testRunStopped (long elapsedTime)
參數 | |
---|---|
elapsedTime |
long |
testStarted
public void testStarted (TestDescription test, long startTime)
參數 | |
---|---|
test |
TestDescription |
startTime |
long |
testStarted
public void testStarted (TestDescription test)
參數 | |
---|---|
test |
TestDescription |
受保護的方法
clearModuleLogFiles
protected final void clearModuleLogFiles ()
允許清除模組檔案,避免長時間保留這些檔案。
clearResultsForName
protected final void clearResultsForName (String testRunName)
可清除指定執行名稱的結果。僅適用於某些情況,例如結果匯總器。
參數 | |
---|---|
testRunName |
String |
setIsAggregrateMetrics
protected void setIsAggregrateMetrics (boolean aggregate)
切換「匯總指標」選項
參數 | |
---|---|
aggregate |
boolean |