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, List<ITestInvocationListener> listeners)
使用指定的逾時時間建立 |
|
公用方法 | |
|---|---|
void
|
testAssumptionFailure(TestDescription test, FailureDescription failure)
當原子測試標記假設為 false 的條件時,系統會呼叫這個函式 |
void
|
testAssumptionFailure(TestDescription test, String trace)
當原子測試標記假設為 false 的條件時,系統會呼叫這個函式 |
void
|
testEnded(TestDescription test, long endTime, HashMap<String, MetricMeasurement.Metric> testMetrics)
|
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)
|
常數
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 的 TimeUnit。 |
listeners |
ITestInvocationListener:要轉送的 ITestInvocationListener。 |
TestTimeoutEnforcer
public TestTimeoutEnforcer (long perTestCaseTimeout,
TimeUnit unit,
List<ITestInvocationListener> listeners)使用指定的強制逾時時間建立 TestTimeoutEnforcer。
| 參數 | |
|---|---|
perTestCaseTimeout |
long:逾時值。 |
unit |
TimeUnit:perTestCaseTimeout 的 TimeUnit。 |
listeners |
List:要轉送的 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, HashMap<String, MetricMeasurement.Metric> testMetrics)
testEnded(TestDescription,Map) 的替代方案,可直接指定結束時間。搭配 testStarted(TestDescription,long) 使用,可準確測量。
| 參數 | |
|---|---|
test |
TestDescription:識別測試 |
endTime |
long:測試結束時間,透過 System.currentTimeMillis() 測量 |
testMetrics |
HashMap:發出的指標 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(TestDescription) 的替代方案,我們也會指定測試開始時間,並搭配 testEnded(TestDescription,long,Map) 進行準確的評估。
| 參數 | |
|---|---|
test |
TestDescription:識別測試 |
startTime |
long:測試開始時間,透過 System.currentTimeMillis() 測量 |