模塊監聽器
public class ModuleListener
extends CollectingTestListener
java.lang.Object | ||
↳ | com.android.tradefed.result.CollectingTestListener | |
↳ | com.android.tradefed.testtype.suite.ModuleListener |
附加到每個模塊的每個IRemoteTest
偵聽器,以收集結果列表。
概括
公共構造函數 | |
---|---|
ModuleListener ( ITestInvocationListener listener, IInvocationContext moduleContext) 構造函數。 |
公共方法 | |
---|---|
boolean | hasLastAttemptFailed () 返回偵聽器上次重試會話是否失敗。 |
void | logAssociation (String dataName, LogFile logFile) 在某些情況下,日誌必須與測試用例強關聯,但有機會這樣做就直接 |
void | setAttemptIsolation ( CurrentInvocation.IsolationGrade isolation) 設置嘗試是否應報告為已隔離。 |
void | setCollectTestsOnly (boolean collectTestsOnly) 設置我們是否只收集測試。 |
void | setMarkTestsSkipped (boolean skip) 是否標記所有已跳過的測試用例。 |
void | setTestMappingSources ( testMappingSources) setTestMappingSources ( testMappingSources) 設置將插入到指標中的測試映射源。 |
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) 當測試不會運行時調用,通常是因為測試方法用 org.junit.Ignore 註釋。 |
void | testLog (String dataName, LogDataType dataType, InputStreamSource dataStream) |
void | testLogSaved (String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile) |
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, int attemptNumber, long startTime) 報告測試運行的開始。 |
void | testStarted ( TestDescription test, long startTime) |
公共構造函數
模塊監聽器
public ModuleListener (ITestInvocationListener listener, IInvocationContext moduleContext)
構造函數。
參數 | |
---|---|
listener | ITestInvocationListener |
moduleContext | IInvocationContext |
公共方法
上次嘗試失敗
public boolean hasLastAttemptFailed ()
返回偵聽器上次重試會話是否失敗。
退貨 | |
---|---|
boolean |
日誌關聯
public 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 ,應該與測試用例相關聯。 |
設置嘗試隔離
public void setAttemptIsolation (CurrentInvocation.IsolationGrade isolation)
設置嘗試是否應報告為已隔離。
參數 | |
---|---|
isolation | CurrentInvocation.IsolationGrade |
setCollectTestsOnly
public void setCollectTestsOnly (boolean collectTestsOnly)
設置我們是否只收集測試。
參數 | |
---|---|
collectTestsOnly | boolean |
setMarkTestsSkipped
public void setMarkTestsSkipped (boolean skip)
是否標記所有已跳過的測試用例。
參數 | |
---|---|
skip | boolean |
setTestMappingSources
public void setTestMappingSources (testMappingSources)
設置將插入到指標中的測試映射源。
參數 | |
---|---|
testMappingSources |
測試假設失敗
public void testAssumptionFailure (TestDescription test, String trace)
當原子測試標記它假定條件為假時調用
參數 | |
---|---|
test | TestDescription :標識測試 |
trace | String :失敗的堆棧跟踪 |
測試假設失敗
public void testAssumptionFailure (TestDescription test, FailureDescription failure)
當原子測試標記它假定條件為假時調用
參數 | |
---|---|
test | TestDescription :標識測試 |
failure | FailureDescription :描述故障及其上下文的FailureDescription 。 |
測試結束
public 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 :測試結束的時間,通過ERROR(/System#currentTimeMillis()) 測量 |
testMetrics | ERROR(/Map) |
測試結束
public void testEnded (TestDescription test,testMetrics)
報告單個測試用例的執行結束。
如果未調用testFailed(TestDescription, FailureDescription)
,則此測試通過。還返回在測試用例執行期間可能發出的任何鍵/值指標。
參數 | |
---|---|
test | TestDescription :標識測試 |
testMetrics | ERROR(/Map) |
測試失敗
public void testFailed (TestDescription test, FailureDescription failure)
報告單個測試用例的失敗。
將在 testStarted 和 testEnded 之間調用。
參數 | |
---|---|
test | TestDescription :標識測試 |
failure | FailureDescription :描述故障及其上下文的FailureDescription 。 |
測試失敗
public void testFailed (TestDescription test, String trace)
報告單個測試用例的失敗。
將在 testStarted 和 testEnded 之間調用。
參數 | |
---|---|
test | TestDescription :標識測試 |
trace | String :失敗的堆棧跟踪 |
測試忽略
public void testIgnored (TestDescription test)
當測試不會運行時調用,通常是因為測試方法用 org.junit.Ignore 註釋。
參數 | |
---|---|
test | TestDescription :標識測試 |
測試日誌
public void testLog (String dataName, LogDataType dataType, InputStreamSource dataStream)
參數 | |
---|---|
dataName | String |
dataType | LogDataType |
dataStream | InputStreamSource |
測試日誌已保存
public void testLogSaved (String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)
參數 | |
---|---|
dataName | String |
dataType | LogDataType |
dataStream | InputStreamSource |
logFile | LogFile |
測試運行結束
public void testRunEnded (long elapsedTime,runMetrics)
報告測試運行結束。 FIXME: 我們不能有兩個不同類型的 Map<> 接口,所以我們必須在這裡使用 HashMap。
參數 | |
---|---|
elapsedTime | long :設備報告經過的時間,以毫秒為單位 |
runMetrics | Metric 報告的鍵值對。 |
測試運行失敗
public void testRunFailed (FailureDescription failure)
由於FailureDescription
描述的故障,報告測試運行未能完成。
參數 | |
---|---|
failure | FailureDescription :描述故障及其上下文的FailureDescription 。 |
測試運行失敗
public void testRunFailed (String errorMessage)
報告測試運行由於致命錯誤而未能完成。
參數 | |
---|---|
errorMessage | String : ERROR(/String) 描述運行失敗的原因。 |
測試運行開始
public void testRunStarted (String name, int numTests, int attemptNumber)
報告測試運行的開始。
參數 | |
---|---|
name | String : 測試運行名稱 |
numTests | int : 測試運行中的測試總數 |
attemptNumber | int : order number,標識同一 runName 多次運行的不同嘗試。 attemptNumber 是從 0 開始索引的,每次發生新的運行時都應該遞增。例如,一個測試被精細地重試了 3 次,它應該在同一個 runName 下總共運行 4 次,並且 attemptNumber 是從 0 到 3。 |
測試運行開始
public void testRunStarted (String name, int numTests, int attemptNumber, long startTime)
報告測試運行的開始。
參數 | |
---|---|
name | String : 測試運行名稱 |
numTests | int : 測試運行中的測試總數 |
attemptNumber | int : order number,標識同一 runName 多次運行的不同嘗試。 attemptNumber 是從 0 開始索引的,每次發生新的運行時都應該遞增。例如,一個測試被精細地重試了 3 次,它應該在相同的 runName 下總共運行 4 次,並且 attemptNumber 是從 0 到 3。 |
startTime | long :運行開始的時間,通過ERROR(/System#currentTimeMillis()) 測量 |
測試開始
public 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 :測試開始的時間,通過ERROR(/System#currentTimeMillis()) 測量 |