TestTimeoutEnforcer
public
final
class
TestTimeoutEnforcer
extends ResultForwarder
java.lang.Object | ||
↳ | com.android.tradefed.result.ResultForwarder | |
↳ | com.android.tradefed.testtype.TestTimeoutEnforcer |
Listeners that allows to check the execution time of a given test case and fail it if it goes over a given timeout.
Note that this enforcer doesn't interrupt the tests, but will make them fail.
Summary
Fields | |
---|---|
public
static
final
String |
TEST_CASE_TIMEOUT_DESCRIPTION
|
public
static
final
String |
TEST_CASE_TIMEOUT_OPTION
|
Public constructors | |
---|---|
TestTimeoutEnforcer(long perTestCaseTimeout, TimeUnit unit, ITestInvocationListener... listeners)
Create the |
|
TestTimeoutEnforcer(long perTestCaseTimeout, TimeUnit unit,
Create the |
Public methods | |
---|---|
void
|
testAssumptionFailure(TestDescription test, FailureDescription failure)
Called when an atomic test flags that it assumes a condition that is false |
void
|
testAssumptionFailure(TestDescription test, String trace)
Called when an atomic test flags that it assumes a condition that is false |
void
|
testEnded(TestDescription test, long endTime,
Alternative to |
void
|
testFailed(TestDescription test, FailureDescription failure)
Reports the failure of a individual test case. |
void
|
testFailed(TestDescription test, String trace)
Reports the failure of a individual test case. |
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)
Alternative to |
Fields
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 constructors
TestTimeoutEnforcer
public TestTimeoutEnforcer (long perTestCaseTimeout, TimeUnit unit, ITestInvocationListener... listeners)
Create the TestTimeoutEnforcer
with the given timeout to enforce.
Parameters | |
---|---|
perTestCaseTimeout |
long : The value of the timeout. |
unit |
TimeUnit : The ERROR(/TimeUnit) of the perTestCaseTimeout. |
listeners |
ITestInvocationListener : The ITestInvocationListener to forward to. |
TestTimeoutEnforcer
public TestTimeoutEnforcer (long perTestCaseTimeout, TimeUnit unit,listeners)
Create the TestTimeoutEnforcer
with the given timeout to enforce.
Parameters | |
---|---|
perTestCaseTimeout |
long : The value of the timeout. |
unit |
TimeUnit : The ERROR(/TimeUnit) of the perTestCaseTimeout. |
listeners |
: The ITestInvocationListener to forward to. |
Public methods
testAssumptionFailure
public void testAssumptionFailure (TestDescription test, FailureDescription failure)
Called when an atomic test flags that it assumes a condition that is false
Parameters | |
---|---|
test |
TestDescription : identifies the test |
failure |
FailureDescription : FailureDescription describing the failure and its context. |
testAssumptionFailure
public void testAssumptionFailure (TestDescription test, String trace)
Called when an atomic test flags that it assumes a condition that is false
Parameters | |
---|---|
test |
TestDescription : identifies the test |
trace |
String : stack trace of failure |
testEnded
public void testEnded (TestDescription test, long endTime,testMetrics)
Alternative to ERROR(/#testEnded(com.android.tradefed.result.TestDescription,Map))
where we can specify the end time
directly. Combine with testStarted(com.android.tradefed.result.TestDescription, long)
for accurate measure.
Parameters | |
---|---|
test |
TestDescription : identifies the test |
endTime |
long : the time the test ended, measured via System.currentTimeMillis() |
testMetrics |
: a ERROR(/Map) of the metrics emitted |
testFailed
public void testFailed (TestDescription test, FailureDescription failure)
Reports the failure of a individual test case.
Will be called between testStarted and testEnded.
Parameters | |
---|---|
test |
TestDescription : identifies the test |
failure |
FailureDescription : FailureDescription describing the failure and its context. |
testFailed
public void testFailed (TestDescription test, String trace)
Reports the failure of a individual test case.
Will be called between testStarted and testEnded.
Parameters | |
---|---|
test |
TestDescription : identifies the test |
trace |
String : stack trace of failure |
testIgnored
public void testIgnored (TestDescription test)
Called when a test will not be run, generally because a test method is annotated with org.junit.Ignore.
Parameters | |
---|---|
test |
TestDescription : identifies the test |
testStarted
public void testStarted (TestDescription test, long startTime)
Alternative to testStarted(com.android.tradefed.result.TestDescription)
where we also specify when the test was
started, combined with ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,Map))
for accurate measure.
Parameters | |
---|---|
test |
TestDescription : identifies the test |
startTime |
long : the time the test started, measured via System.currentTimeMillis() |