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 |
提供 IRemoteTest
和 IDeviceTest
服务的辅助 JUnit 测试用例。
如果您想实现遵循 JUnit 测试定义模式的测试,同时仍能完全支持其他 Trade Federation 功能(例如 Option
),这会很有用
摘要
字段 | |
---|---|
protected
|
mExcludeAnnotation
要运行的测试的排除注解 |
protected
|
mExcludeFilters
要运行的测试名称的排除过滤条件 |
protected
|
mIncludeAnnotation
要运行的测试的 include 注解 |
protected
|
mIncludeFilters
要运行的测试名称的包含过滤条件 |
公共构造函数 | |
---|---|
DeviceTestCase()
|
|
DeviceTestCase(String name)
|
公共方法 | |
---|---|
void
|
addAllExcludeAnnotation(
添加了 |
void
|
addAllExcludeFilters(
添加了要排除的测试的过滤条件的 |
void
|
addAllIncludeAnnotation(
添加了 |
void
|
addAllIncludeFilters(
添加要包含的测试的过滤条件的 |
void
|
addExcludeAnnotation(String notAnnotation)
添加了注解,用于排除被标记为包含该注解的测试。 |
void
|
addExcludeFilter(String filter)
添加了用于过滤要排除的测试的过滤条件。 |
void
|
addIncludeAnnotation(String annotation)
添加了注解,用于在测试被标记时进行包含。 |
void
|
addIncludeFilter(String filter)
添加了用于过滤要包含的测试的过滤条件。 |
void
|
clearExcludeAnnotations()
删除当前跟踪的所有排除注释。 |
void
|
clearExcludeFilters()
删除目前跟踪的所有排除过滤条件。 |
void
|
clearIncludeAnnotations()
删除当前跟踪的所有包含注释。 |
void
|
clearIncludeFilters()
删除当前跟踪的所有包含过滤条件。 |
int
|
countTestCases()
|
ITestDevice
|
getDevice()
获取被测设备。 |
|
getExcludeAnnotations()
返回要排除的注释的当前 |
|
getExcludeFilters()
返回排除过滤条件的当前 |
|
getIncludeAnnotations()
返回要包含的注释的当前 |
|
getIncludeFilters()
返回包含过滤条件的当前 |
void
|
run(TestResult result)
如果要运行的测试方法为 null,则替换父级方法以运行所有测试方法。 |
void
|
run(TestInformation testInfo, ITestInvocationListener listener)
运行测试并向监听器报告结果。 |
void
|
setCollectTestsOnly(boolean shouldCollectTest)
启用或停用测试集合模式 |
void
|
setDevice(ITestDevice device)
注入被测设备。 |
字段
mExcludeAnnotation
protectedmExcludeAnnotation
要运行的测试的排除注解
mExcludeFilters
protectedmExcludeFilters
要运行的测试名称的排除过滤条件
mIncludeAnnotation
protectedmIncludeAnnotation
要运行的测试的 include 注解
mIncludeFilters
protectedmIncludeFilters
要运行的测试名称的包含过滤条件
公共构造函数
DeviceTestCase
public DeviceTestCase ()
DeviceTestCase
public DeviceTestCase (String name)
参数 | |
---|---|
name |
String |
公共方法
addAllExcludeAnnotation
public void addAllExcludeAnnotation (notAnnotations)
添加了 ERROR(/Set)
注解,以便在测试被标记为包含该注解时进行排除。
参数 | |
---|---|
notAnnotations |
|
addAllExcludeFilters
public void addAllExcludeFilters (filters)
添加了要排除的测试的过滤条件的 ERROR(/Set)
。
参数 | |
---|---|
filters |
|
addAllIncludeAnnotation
public void addAllIncludeAnnotation (annotations)
添加了 ERROR(/Set)
注解,以便在测试被标记为包含该注解时进行包含。
参数 | |
---|---|
annotations |
|
addAllIncludeFilters
public void addAllIncludeFilters (filters)
添加了要包含的测试的过滤条件的 ERROR(/Set)
。
参数 | |
---|---|
filters |
|
addExcludeAnnotation
public void addExcludeAnnotation (String notAnnotation)
添加了注解,用于排除被标记为包含该注解的测试。
参数 | |
---|---|
notAnnotation |
String |
addExcludeFilter
public void addExcludeFilter (String filter)
添加了用于过滤要排除的测试的过滤条件。
参数 | |
---|---|
filter |
String |
addIncludeAnnotation
public void addIncludeAnnotation (String annotation)
添加了注解,以便在测试被标记时包含该注解。
参数 | |
---|---|
annotation |
String |
addIncludeFilter
public void addIncludeFilter (String filter)
添加了用于过滤要包含的测试的过滤条件。
参数 | |
---|---|
filter |
String |
clearExcludeAnnotations
public void clearExcludeAnnotations ()
删除当前跟踪的所有排除注释。
clearExcludeFilters
public void clearExcludeFilters ()
删除当前跟踪的所有排除过滤条件。
clearIncludeAnnotations
public void clearIncludeAnnotations ()
删除当前跟踪的所有包含注释。
clearIncludeFilters
public void clearIncludeFilters ()
删除当前跟踪的所有包含过滤条件。
countTestCases
public int countTestCases ()
返回 | |
---|---|
int |
得分
public void run (TestResult result)
如果要运行的测试方法为 null,则替换父级方法以运行所有测试方法。
JUnit 框架仅支持通过将 TestCase 封装在 TestSuite 中来运行 TestCase 中的所有测试。遗憾的是,使用此机制时,调用方无法控制自己的测试用例的生命周期,因此无法执行诸如让 Tradefed 配置框架将选项注入测试用例之类的操作。
参数 | |
---|---|
result |
TestResult |
得分
public void run (TestInformation testInfo, ITestInvocationListener listener)
运行测试并向监听器报告结果。
参数 | |
---|---|
testInfo |
TestInformation :包含运行测试的实用信息的 TestInformation 对象。 |
listener |
ITestInvocationListener :测试结果的 ITestInvocationListener |
抛出 | |
---|---|
DeviceNotAvailableException |
setCollectTestsOnly
public void setCollectTestsOnly (boolean shouldCollectTest)
启用或停用测试集合模式