ITestLifeCycleReceiver
public interface ITestLifeCycleReceiver
com.android.tradefed.result.ITestLifeCycleReceiver |
在儀器測試運行期間接收事件通知。
模仿 org.junit.runner.notification.RunListener
調用的順序將是:
- 測試運行開始
- 測試開始
- [測試失敗]
- [測試假設失敗]
- [測試忽略]
- 測試結束
- ....
- [測試運行失敗]
- 測試運行結束
概括
公共方法 | |
---|---|
default void | testAssumptionFailure ( TestDescription test, String trace) 當原子測試標記其假定條件為 false 時調用 |
default void | testAssumptionFailure ( TestDescription test, FailureDescription failure) 當原子測試標記其假定條件為 false 時調用 |
default void | testEnded ( TestDescription test, long endTime, testMetrics) testEnded ( TestDescription test, long endTime, testMetrics) |
default void | testEnded ( TestDescription test, testMetrics) testEnded ( TestDescription test, testMetrics) 報告單個測試用例的執行結束。 |
default void | testFailed ( TestDescription test, FailureDescription failure) 報告單個測試用例的失敗。 |
default void | testFailed ( TestDescription test, String trace) 報告單個測試用例的失敗。 |
default void | testIgnored ( TestDescription test) 當測試不會運行時調用,通常是因為測試方法用 org.junit.Ignore 註解。 |
default void | testRunEnded (long elapsedTimeMillis, runMetrics) testRunEnded (long elapsedTimeMillis, runMetrics) 報告測試運行結束。 |
default void | testRunFailed ( FailureDescription failure) 報告測試運行由於 |
default void | testRunFailed (String errorMessage) 報告測試運行由於致命錯誤而未能完成。 |
default void | testRunStarted (String runName, int testCount, int attemptNumber) 報告測試運行的開始。 |
default void | testRunStarted (String runName, int testCount) 報告測試運行的開始。 |
default void | testRunStarted (String runName, int testCount, int attemptNumber, long startTime) 報告測試運行的開始。 |
default void | testRunStopped (long elapsedTime) 由於用戶請求,報告測試運行在完成之前停止。 |
default void | testStarted ( TestDescription test, long startTime) |
default void | testStarted ( TestDescription test) 報告單個測試用例的開始。 |
公共方法
測試假設失敗
public void testAssumptionFailure (TestDescription test, String trace)
當原子測試標記其假定條件為 false 時調用
參數 | |
---|---|
test | TestDescription :標識測試 |
trace | String : 失敗的堆棧跟踪 |
測試假設失敗
public void testAssumptionFailure (TestDescription test, FailureDescription failure)
當原子測試標記其假定條件為 false 時調用
參數 | |
---|---|
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 :測試結束的時間,通過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 testRunEnded (long elapsedTimeMillis,runMetrics)
報告測試運行結束。 FIXME:我們不能有兩個不同類型的 Map<> 接口,所以我們必須在這裡使用 HashMap。
參數 | |
---|---|
elapsedTimeMillis | long :設備報告的經過時間,以毫秒為單位 |
runMetrics | Metric 測試運行結束時報告的鍵值對。 |
測試運行失敗
public void testRunFailed (FailureDescription failure)
報告測試運行由於FailureDescription
描述的故障而未能完成。
參數 | |
---|---|
failure | FailureDescription :描述故障及其上下文的FailureDescription 。 |
測試運行失敗
public void testRunFailed (String errorMessage)
報告測試運行由於致命錯誤而未能完成。
參數 | |
---|---|
errorMessage | String :描述運行失敗原因的String 。 |
測試運行開始
public void testRunStarted (String runName, int testCount, int attemptNumber)
報告測試運行的開始。
參數 | |
---|---|
runName | String : 測試運行名稱 |
testCount | int : 測試運行中的測試總數 |
attemptNumber | int :訂單號,標識同一 runName 多次運行的不同嘗試。 attemptsNumber 是從 0 開始索引的,並且每次新的運行發生時都應該遞增。例如,一個測試被粒度重試 3 次,它應該在同一 runName 下總共運行 4 次,並且 attemptsNumber 從 0 到 3。 |
測試運行開始
public 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 多次運行的不同嘗試。 attemptsNumber 是從 0 開始索引的,並且每次新的運行發生時都應該遞增。例如,一個測試被粒度重試 3 次,它應該在同一 runName 下總共運行 4 次,並且 attemptsNumber 從 0 到 3。 |
startTime | long :運行開始的時間,通過System.currentTimeMillis() 測量 |
測試運行停止
public void testRunStopped (long elapsedTime)
由於用戶請求,報告測試運行在完成之前停止。
TODO:當前未使用,考慮刪除
參數 | |
---|---|
elapsedTime | long :設備報告的經過時間,以毫秒為單位 |
測試開始
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 :測試開始的時間,通過System.currentTimeMillis() 測量 |
測試開始
public void testStarted (TestDescription test)
報告單個測試用例的開始。較舊的接口,應盡可能使用testStarted(com.android.tradefed.result.TestDescription)
。
參數 | |
---|---|
test | TestDescription :標識測試 |