TestTimeoutEnforcer

public final class TestTimeoutEnforcer
extends ResultForwarder

java.lang.Object
   ↳ com.android.tradefed.result.ResultForwarder
     ↳ com.android.tradefed.testtype.TestTimeoutEnforcer


可讓您檢查指定測試案例的執行時間,並在超過指定逾時時間時失敗的事件監聽器。

請注意,這個強制執行程序不會中斷測試,但會導致測試失敗。

摘要

欄位

public static final String TEST_CASE_TIMEOUT_DESCRIPTION

public static final String TEST_CASE_TIMEOUT_OPTION

公用建構函式

TestTimeoutEnforcer(long perTestCaseTimeout, TimeUnit unit, ITestInvocationListener... listeners)

使用指定的逾時期限建立 TestTimeoutEnforcer

TestTimeoutEnforcer(long perTestCaseTimeout, TimeUnit unit, listeners)

使用指定的逾時期限建立 TestTimeoutEnforcer

公用方法

void testAssumptionFailure(TestDescription test, FailureDescription failure)

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

void testAssumptionFailure(TestDescription test, String trace)

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

void testEnded(TestDescription test, long endTime, testMetrics)

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

void testFailed(TestDescription test, FailureDescription failure)

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

void testFailed(TestDescription test, String trace)

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

void testIgnored(TestDescription test)

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

void testStarted(TestDescription test, long startTime)

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

欄位

TEST_CASE_TIMEOUT_DESCRIPTION

public static final String TEST_CASE_TIMEOUT_DESCRIPTION

TEST_CASE_TIMEOUT_OPTION

public static final String TEST_CASE_TIMEOUT_OPTION

公用建構函式

TestTimeoutEnforcer

public TestTimeoutEnforcer (long perTestCaseTimeout, 
                TimeUnit unit, 
                ITestInvocationListener... listeners)

使用指定的逾時期限建立 TestTimeoutEnforcer

參數
perTestCaseTimeout long:逾時值。

unit TimeUnit:perTestCaseTimeout 的 ERROR(/TimeUnit)

listeners ITestInvocationListener:要轉送至的 ITestInvocationListener

TestTimeoutEnforcer

public TestTimeoutEnforcer (long perTestCaseTimeout, 
                TimeUnit unit, 
                 listeners)

使用指定的逾時期限建立 TestTimeoutEnforcer

參數
perTestCaseTimeout long:逾時值。

unit TimeUnit:perTestCaseTimeout 的 ERROR(/TimeUnit)

listeners :要轉送至的 ITestInvocationListener

公用方法

testAssumptionFailure

public void testAssumptionFailure (TestDescription test, 
                FailureDescription failure)

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

參數
test TestDescription:用於識別測試

failure FailureDescriptionFailureDescription 可說明失敗和相關情境。

testAssumptionFailure

public void testAssumptionFailure (TestDescription test, 
                String trace)

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

參數
test TestDescription:用於識別測試

trace String:失敗的堆疊追蹤

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)

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:用於識別測試

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