测试超时执行器
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) 当原子测试标记它假定条件为假时调用 |
void | testAssumptionFailure ( TestDescription test, String trace) 当原子测试标记它假定条件为假时调用 |
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)
当原子测试标记它假定条件为假时调用
参数 | |
---|---|
test | TestDescription :标识测试 |
failure | FailureDescription :描述故障及其上下文的FailureDescription 。 |
测试假设失败
public void testAssumptionFailure (TestDescription test, String trace)
当原子测试标记它假定条件为假时调用
参数 | |
---|---|
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 :测试结束的时间,通过ERROR(/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 :测试开始的时间,通过ERROR(/System#currentTimeMillis()) 测量 |