測試逾時執行器
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 (long perTestCaseTimeout, TimeUnit unit, listeners) TestTimeoutEnforcer (long perTestCaseTimeout, TimeUnit unit, listeners) 建立具有要強制執行的給定逾時的 |
公共方法 | |
---|---|
void | testAssumptionFailure ( TestDescription test, FailureDescription failure) 當原子測試標記其假定條件為 false 時調用 |
void | testAssumptionFailure ( TestDescription test, String trace) 當原子測試標記其假定條件為 false 時調用 |
void | testEnded ( TestDescription test, long endTime, testMetrics) testEnded ( TestDescription test, long endTime, 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
公共構造函數
測試逾時執行器
public TestTimeoutEnforcer (long perTestCaseTimeout, TimeUnit unit, ITestInvocationListener... listeners)
建立具有要強制執行的給定逾時的TestTimeoutEnforcer
。
參數 | |
---|---|
perTestCaseTimeout | long :超時值。 |
unit | TimeUnit :perTestCaseTimeout 的ERROR(/TimeUnit) 。 |
listeners | ITestInvocationListener :要轉送的ITestInvocationListener 。 |
測試逾時執行器
public TestTimeoutEnforcer (long perTestCaseTimeout, TimeUnit unit,listeners)
建立具有要強制執行的給定逾時的TestTimeoutEnforcer
。
參數 | |
---|---|
perTestCaseTimeout | long :超時值。 |
unit | TimeUnit :perTestCaseTimeout 的ERROR(/TimeUnit) 。 |
listeners | ITestInvocationListener 。 |
公共方法
測試假設失敗
public void testAssumptionFailure (TestDescription test, FailureDescription failure)
當原子測試標記其假定條件為 false 時調用
參數 | |
---|---|
test | TestDescription :標識測試 |
failure | FailureDescription :描述故障及其上下文的FailureDescription 。 |
測試假設失敗
public void testAssumptionFailure (TestDescription test, String trace)
當原子測試標記其假定條件為 false 時調用
參數 | |
---|---|
test | TestDescription :標識測試 |
trace | String : 失敗的堆疊追蹤 |
測試結束
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 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 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() 測量 |