ITestLifeCycleReceiver

public interface ITestLifeCycleReceiver

com.android.tradefed.result.ITestLifeCycleReceiver


在檢測工具測試執行期間接收事件通知。

模仿 org.junit.runner.notification.RunListener

呼叫的順序如下:

  • testRunStarted
  • testStarted
  • [testFailed]
  • [testAssumptionFailure]
  • [testIgnored]
  • testEnded
  • ....
  • [testRunFailed]
  • testRunEnded

摘要

公用方法

default void testAssumptionFailure(TestDescription test, String trace)

當原子測試標記假設條件為 false 時,系統會呼叫此方法

default void testAssumptionFailure(TestDescription test, FailureDescription failure)

當原子測試標記假設條件為 false 時,系統會呼叫此方法

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

ERROR(/#testEnded(com.android.tradefed.result.TestDescription,Map)) 的替代方案,可直接指定結束時間。

default void 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)

回報測試執行結束。

default void testRunFailed(FailureDescription failure)

由於 FailureDescription 所述的錯誤,無法完成報表測試執行作業。

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 testSkipped(TestDescription test, SkipReason reason)

當測試遭到略過,且未因通常預期的原因而執行時,系統會呼叫此方法。

default void testStarted(TestDescription test, long startTime)

testStarted(com.android.tradefed.result.TestDescription) 的替代方案,我們也會指定測試開始時間,並搭配 ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,Map)) 進行精確評估。

default void testStarted(TestDescription test)

回報個別測試案例的開始時間。

公用方法

testAssumptionFailure

public void testAssumptionFailure (TestDescription test, 
                String trace)

當原子測試標記假設條件為 false 時,系統會呼叫此方法

參數
test TestDescription:用於識別測試

trace String:失敗的堆疊追蹤

testAssumptionFailure

public void testAssumptionFailure (TestDescription test, 
                FailureDescription failure)

當原子測試標記假設條件為 false 時,系統會呼叫此方法

參數
test TestDescription:用於識別測試

failure FailureDescriptionFailureDescription 可說明失敗和其情境。

testEnded

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)

testEnded

public void testEnded (TestDescription test, 
                 testMetrics)

回報個別測試案例的執行結束時間。

如果未叫用 testFailed(TestDescription, FailureDescription),則表示這項測試已通過。也會傳回在測試案例執行期間可能已發出的任何鍵/值指標。

參數
test TestDescription:用於識別測試

testMetrics :傳送指標的 ERROR(/Map)

testFailed

public void testFailed (TestDescription test, 
                FailureDescription failure)

回報個別測試案例的失敗情形。

會在 testStarted 和 testEnded 之間呼叫。

參數
test TestDescription:用於識別測試

failure FailureDescriptionFailureDescription 可說明失敗和其情境。

testFailed

public void testFailed (TestDescription test, 
                String trace)

回報個別測試案例的失敗情形。

會在 testStarted 和 testEnded 之間呼叫。

參數
test TestDescription:用於識別測試

trace String:失敗的堆疊追蹤

testIgnored

public void testIgnored (TestDescription test)

當測試不會執行時,系統會呼叫此方法,通常是因為測試方法已標註為 org.junit.Ignore。

參數
test TestDescription:用於識別測試

testRunEnded

public void testRunEnded (long elapsedTimeMillis, 
                 runMetrics)

回報測試執行結束。

參數
elapsedTimeMillis long:裝置回報的經過時間,以毫秒為單位

runMetrics :測試執行結束時回報的鍵/值組合

testRunFailed

public void testRunFailed (FailureDescription failure)

由於 FailureDescription 所述的錯誤,導致報表測試執行作業無法完成。

參數
failure FailureDescriptionFailureDescription 可說明失敗和其情境。

testRunFailed

public void testRunFailed (String errorMessage)

由於發生致命錯誤,報表測試執行作業無法完成。

參數
errorMessage StringString,說明執行失敗的原因。

testRunStarted

public void testRunStarted (String runName, 
                int testCount, 
                int attemptNumber)

回報測試執行作業的開始時間。

參數
runName String:測試執行作業名稱

testCount int:測試執行作業中的測試總數

attemptNumber int:訂單號碼,用於識別同一個 runName 執行多次的不同嘗試。attemptNumber 的索引為 0,每次執行時都應遞增。舉例來說,如果測試重試 3 次,則在相同的 runName 下,應有 4 次執行,而 attemptNumber 則從 0 到 3。

testRunStarted

public void testRunStarted (String runName, 
                int testCount)

回報測試執行作業的開始時間。

參數
runName String:測試執行作業名稱

testCount int:測試執行作業中的測試總數

testRunStarted

public void testRunStarted (String runName, 
                int testCount, 
                int attemptNumber, 
                long startTime)

回報測試執行作業的開始時間。

參數
runName String:測試執行作業名稱

testCount int:測試執行作業中的測試總數

attemptNumber int:訂單號碼,用於識別同一個 runName 執行多次的不同嘗試。attemptNumber 的索引為 0,每次執行時都應遞增。舉例來說,如果測試重試 3 次,則在相同的 runName 下,應有 4 次執行,而 attemptNumber 則從 0 到 3。

startTime long:透過 System.currentTimeMillis() 測量的執行作業開始時間

testRunStopped

public void testRunStopped (long elapsedTime)

報表測試在使用者要求下,在完成前停止執行。

TODO:目前未使用,建議移除

參數
elapsedTime long:裝置回報的經過時間,以毫秒為單位

testSkipped

public void testSkipped (TestDescription test, 
                SkipReason reason)

當測試遭到略過,且未因通常預期的原因而執行時,系統會呼叫此方法。系統會嘗試重試這些測試,以便取得正確的執行結果。

參數
test TestDescription:用於識別測試

reason SkipReasonSkipReason

testStarted

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() 測量

testStarted

public void testStarted (TestDescription test)

回報個別測試案例的開始時間。較舊的介面,應盡可能使用 testStarted(com.android.tradefed.result.TestDescription)

參數
test TestDescription:用於識別測試