TestTimeoutEnforcer
public
final
class
TestTimeoutEnforcer
extends ResultForwarder
| java.lang.Object | ||
| ↳ | com.android.tradefed.result.ResultForwarder | |
| ↳ | com.android.tradefed.testtype.TestTimeoutEnforcer | |
這個接聽程式可檢查特定測試案例的執行時間,並在超過指定逾時時間時導致測試失敗。
請注意,這項執行者不會中斷測試,但會導致測試失敗。
摘要
常數 | |
|---|---|
String |
TEST_CASE_TIMEOUT_DESCRIPTION
|
String |
TEST_CASE_TIMEOUT_OPTION
|
公用建構函式 | |
|---|---|
TestTimeoutEnforcer(long perTestCaseTimeout, TimeUnit unit, ITestInvocationListener... listeners)
使用指定的逾時時間建立 |
|
TestTimeoutEnforcer(long perTestCaseTimeout, TimeUnit unit,
使用指定的逾時時間建立 |
|
公用方法 | |
|---|---|
void
|
testAssumptionFailure(TestDescription test, FailureDescription failure)
當原子測試標記假設條件為 false 時,系統會呼叫這個函式。 |
void
|
testAssumptionFailure(TestDescription test, String trace)
當原子測試標記假設條件為 false 時,系統會呼叫這個函式。 |
void
|
testEnded(TestDescription test, long endTime,
|
void
|
testFailed(TestDescription test, FailureDescription failure)
回報個別測試案例的失敗情形。 |
void
|
testFailed(TestDescription test, String trace)
回報個別測試案例的失敗情形。 |
void
|
testIgnored(TestDescription test)
Called when a test will not be run, generally because a test method is annotated with org.junit.Ignore. |
void
|
testStarted(TestDescription test, long startTime)
|
常數
TEST_CASE_TIMEOUT_DESCRIPTION
public static final String TEST_CASE_TIMEOUT_DESCRIPTION
常數值: 「將套用至執行階段中每個測試案例的逾時。」
TEST_CASE_TIMEOUT_OPTION
public static final String TEST_CASE_TIMEOUT_OPTION
常數值: "test-case-timeout"
公用建構函式
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 |
FailureDescription:FailureDescription,說明失敗情形和相關情境。 |
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 |
FailureDescription:FailureDescription,說明失敗情形和相關情境。 |
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() 測量 |