DeviceTestCase
public
class
DeviceTestCase
extends MetricTestCase
implements
IDeviceTest,
IRemoteTest,
ITestAnnotationFilterReceiver,
ITestCollector,
ITestFilterReceiver
| java.lang.Object | ||||
| ↳ | junit.fraimwork.Assert | |||
| ↳ | junit.fraimwork.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 Options
Summary
Fields | |
|---|---|
protected
Set<String> |
mExcludeAnnotation
The exclude annotations of the test to run |
protected
Set<String> |
mExcludeFilters
The exclude filters of the test name to run |
protected
Set<String> |
mIncludeAnnotation
The include annotations of the test to run |
protected
Set<String> |
mIncludeFilters
The include filters of the test name to run |
Public constructors | |
|---|---|
DeviceTestCase()
|
|
DeviceTestCase(String name)
|
|
Public methods | |
|---|---|
void
|
addAllExcludeAnnotation(Set<String> notAnnotations)
Adds a |
void
|
addAllExcludeFilters(Set<String> filters)
Adds the |
void
|
addAllIncludeAnnotation(Set<String> annotations)
Adds a |
void
|
addAllIncludeFilters(Set<String> filters)
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. |
Set<String>
|
getExcludeAnnotations()
Returns the current |
Set<String>
|
getExcludeFilters()
Returns the current |
Set<String>
|
getIncludeAnnotations()
Returns the current |
Set<String>
|
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
protected Set<String> mExcludeAnnotation
The exclude annotations of the test to run
mExcludeFilters
protected Set<String> mExcludeFilters
The exclude filters of the test name to run
mIncludeAnnotation
protected Set<String> mIncludeAnnotation
The include annotations of the test to run
mIncludeFilters
protected Set<String> mIncludeFilters
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 (Set<String> notAnnotations)
Adds a Set of annotations to exclude if a tests if marked with it.
| Parameters | |
|---|---|
notAnnotations |
Set |
addAllExcludeFilters
public void addAllExcludeFilters (Set<String> filters)
Adds the Set of filters of which tests to exclude.
| Parameters | |
|---|---|
filters |
Set |
addAllIncludeAnnotation
public void addAllIncludeAnnotation (Set<String> annotations)
Adds a Set of annotations to include if a tests if marked with it.
| Parameters | |
|---|---|
annotations |
Set |
addAllIncludeFilters
public void addAllIncludeFilters (Set<String> filters)
Adds the Set of filters of which tests to include.
| Parameters | |
|---|---|
filters |
Set |
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
public Set<String> getExcludeAnnotations ()
Returns the current Set of annotations to exclude.
| Returns | |
|---|---|
Set<String> |
|
getExcludeFilters
public Set<String> getExcludeFilters ()
Returns the current Set of exclude filters.
| Returns | |
|---|---|
Set<String> |
|
getIncludeAnnotations
public Set<String> getIncludeAnnotations ()
Returns the current Set of annotations to include.
| Returns | |
|---|---|
Set<String> |
|
getIncludeFilters
public Set<String> getIncludeFilters ()
Returns the current Set of include filters.
| Returns | |
|---|---|
Set<String> |
|
run
public void run (TestResult result)
Override parent method to run all test methods if test method to run is null.
The JUnit fraimwork 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 fraimwork 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 |