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

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

常量值: "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() 测量