DeviceTestCase
public
class
DeviceTestCase
extends MetricTestCase
implements
IDeviceTest,
IRemoteTest,
ITestAnnotationFilterReceiver,
ITestCollector,
ITestFilterReceiver
java.lang.Object | ||||
↳ | junit.framework.Assert | |||
↳ | junit.framework.TestCase | |||
↳ | com.android.tradefed.testtype.MetricTestCase | |||
↳ | com.android.tradefed.testtype.DeviceTestCase |
Helper JUnit test case that provides the IRemoteTest
and IDeviceTest
services.
This is useful if you want to implement tests that follow the JUnit pattern of defining tests,
and still have full support for other tradefed features such as Option
s
Summary
Fields | |
---|---|
protected
|
mExcludeAnnotation
The exclude annotations of the test to run |
protected
|
mExcludeFilters
The exclude filters of the test name to run |
protected
|
mIncludeAnnotation
The include annotations of the test to run |
protected
|
mIncludeFilters
The include filters of the test name to run |
Public constructors | |
---|---|
DeviceTestCase()
|
|
DeviceTestCase(String name)
|
Public methods | |
---|---|
void
|
addAllExcludeAnnotation(
Adds a |
void
|
addAllExcludeFilters(
Adds the |
void
|
addAllIncludeAnnotation(
Adds a |
void
|
addAllIncludeFilters(
Adds the |
void
|
addExcludeAnnotation(String notAnnotation)
Adds an annotation to exclude if a tests if marked with it. |
void
|
addExcludeFilter(String filter)
Adds a filter of which tests to exclude. |
void
|
addIncludeAnnotation(String annotation)
Adds an annotation to include if a tests if marked with it. |
void
|
addIncludeFilter(String filter)
Adds a filter of which tests to include. |
void
|
clearExcludeAnnotations()
Delete all the exclude annotations currently tracked. |
void
|
clearExcludeFilters()
Delete all the exclude filters currently tracked. |
void
|
clearIncludeAnnotations()
Delete all the include annotations currently tracked. |
void
|
clearIncludeFilters()
Delete all the include filters currently tracked. |
int
|
countTestCases()
|
ITestDevice
|
getDevice()
Get the device under test. |
|
getExcludeAnnotations()
Returns the current |
|
getExcludeFilters()
Returns the current |
|
getIncludeAnnotations()
Returns the current |
|
getIncludeFilters()
Returns the current |
void
|
run(TestResult result)
Override parent method to run all test methods if test method to run is null. |
void
|
run(TestInformation testInfo, ITestInvocationListener listener)
Runs the tests, and reports result to the listener. |
void
|
setCollectTestsOnly(boolean shouldCollectTest)
Enables or disables test collection mode |
void
|
setDevice(ITestDevice device)
Inject the device under test. |
Fields
mExcludeAnnotation
protectedmExcludeAnnotation
The exclude annotations of the test to run
mExcludeFilters
protectedmExcludeFilters
The exclude filters of the test name to run
mIncludeAnnotation
protectedmIncludeAnnotation
The include annotations of the test to run
mIncludeFilters
protectedmIncludeFilters
The include filters of the test name to run
Public constructors
DeviceTestCase
public DeviceTestCase ()
DeviceTestCase
public DeviceTestCase (String name)
Parameters | |
---|---|
name |
String |
Public methods
addAllExcludeAnnotation
public void addAllExcludeAnnotation (notAnnotations)
Adds a ERROR(/Set)
of annotations to exclude if a tests if marked with it.
Parameters | |
---|---|
notAnnotations |
|
addAllExcludeFilters
public void addAllExcludeFilters (filters)
Adds the ERROR(/Set)
of filters of which tests to exclude.
Parameters | |
---|---|
filters |
|
addAllIncludeAnnotation
public void addAllIncludeAnnotation (annotations)
Adds a ERROR(/Set)
of annotations to include if a tests if marked with it.
Parameters | |
---|---|
annotations |
|
addAllIncludeFilters
public void addAllIncludeFilters (filters)
Adds the ERROR(/Set)
of filters of which tests to include.
Parameters | |
---|---|
filters |
|
addExcludeAnnotation
public void addExcludeAnnotation (String notAnnotation)
Adds an annotation to exclude if a tests if marked with it.
Parameters | |
---|---|
notAnnotation |
String |
addExcludeFilter
public void addExcludeFilter (String filter)
Adds a filter of which tests to exclude.
Parameters | |
---|---|
filter |
String |
addIncludeAnnotation
public void addIncludeAnnotation (String annotation)
Adds an annotation to include if a tests if marked with it.
Parameters | |
---|---|
annotation |
String |
addIncludeFilter
public void addIncludeFilter (String filter)
Adds a filter of which tests to include.
Parameters | |
---|---|
filter |
String |
clearExcludeAnnotations
public void clearExcludeAnnotations ()
Delete all the exclude annotations currently tracked.
clearExcludeFilters
public void clearExcludeFilters ()
Delete all the exclude filters currently tracked.
clearIncludeAnnotations
public void clearIncludeAnnotations ()
Delete all the include annotations currently tracked.
clearIncludeFilters
public void clearIncludeFilters ()
Delete all the include filters currently tracked.
countTestCases
public int countTestCases ()
Returns | |
---|---|
int |
getDevice
public ITestDevice getDevice ()
Get the device under test.
Returns | |
---|---|
ITestDevice |
the ITestDevice |
getExcludeAnnotations
publicgetExcludeAnnotations ()
Returns the current ERROR(/Set)
of annotations to exclude.
Returns | |
---|---|
|
getExcludeFilters
publicgetExcludeFilters ()
Returns the current ERROR(/Set)
of exclude filters.
Returns | |
---|---|
|
getIncludeAnnotations
publicgetIncludeAnnotations ()
Returns the current ERROR(/Set)
of annotations to include.
Returns | |
---|---|
|
getIncludeFilters
publicgetIncludeFilters ()
Returns the current ERROR(/Set)
of include filters.
Returns | |
---|---|
|
run
public void run (TestResult result)
Override parent method to run all test methods if test method to run is null.
The JUnit framework only supports running all the tests in a TestCase by wrapping it in a TestSuite. Unfortunately with this mechanism callers can't control the lifecycle of their own test cases, which makes it impossible to do things like have the tradefed configuration framework inject options into a Test Case.Parameters | |
---|---|
result |
TestResult |
run
public void run (TestInformation testInfo, ITestInvocationListener listener)
Runs the tests, and reports result to the listener.
Parameters | |
---|---|
testInfo |
TestInformation : The TestInformation object containing useful information to run
tests. |
listener |
ITestInvocationListener : the ITestInvocationListener of test results |
Throws | |
---|---|
DeviceNotAvailableException |
setCollectTestsOnly
public void setCollectTestsOnly (boolean shouldCollectTest)
Enables or disables test collection mode
setDevice
public void setDevice (ITestDevice device)
Inject the device under test.
Parameters | |
---|---|
device |
ITestDevice : the ITestDevice to use |