设备测试用例
public class DeviceTestCase
extends MetricTestCase
implements IDeviceTest , IRemoteTest , ITestCollector , ITestFilterReceiver , ITestAnnotationFilterReceiver
java.lang.Object | ||||
↳ | junit.framework.Assert | |||
↳ | junit.framework.TestCase | |||
↳ | com.android.tradefed.testtype.MetricTestCase | |||
↳ | com.android.tradefed.testtype.DeviceTestCase |
提供IRemoteTest
和IDeviceTest
服务的 Helper JUnit 测试用例。
如果您想要实现遵循定义测试的 JUnit 模式的测试,并且仍然完全支持其他 tradefed 功能(例如Option
),那么这非常有用
概括
领域 | |
---|---|
protected | mExcludeAnnotation 要运行的测试的排除注释 |
protected | mExcludeFilters 要运行的测试名称的排除过滤器 |
protected | mIncludeAnnotation 包含要运行的测试的注释 |
protected | mIncludeFilters 要运行的测试名称的包含过滤器 |
公共构造函数 | |
---|---|
DeviceTestCase () | |
DeviceTestCase (String name) |
公共方法 | |
---|---|
void | addAllExcludeAnnotation ( notAnnotations) addAllExcludeAnnotation ( notAnnotations) 添加 |
void | addAllExcludeFilters ( filters) addAllExcludeFilters ( filters) 添加要排除的测试的过滤器的 |
void | addAllIncludeAnnotation ( annotations) addAllIncludeAnnotation ( annotations) 添加 |
void | addAllIncludeFilters ( filters) addAllIncludeFilters ( filters) 添加要包含的测试的过滤器的 |
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
要运行的测试的排除注释
m排除过滤器
protectedmExcludeFilters
要运行的测试名称的排除过滤器
mIncludeAnnotation
protectedmIncludeAnnotation
包含要运行的测试的注释
m包含过滤器
protectedmIncludeFilters
要运行的测试名称的包含过滤器
公共构造函数
设备测试用例
public DeviceTestCase ()
设备测试用例
public DeviceTestCase (String name)
参数 | |
---|---|
name | String |
公共方法
添加全部排除注释
public void addAllExcludeAnnotation (notAnnotations)
添加ERROR(/Set)
注释以排除测试是否用它标记。
参数 | |
---|---|
notAnnotations |
添加排除注释
public void addExcludeAnnotation (String notAnnotation)
添加注释以排除测试是否用它标记。
参数 | |
---|---|
notAnnotation | String |
添加排除过滤器
public void addExcludeFilter (String filter)
添加要排除的测试的过滤器。
参数 | |
---|---|
filter | String |
添加包含注释
public void addIncludeAnnotation (String annotation)
添加注释以包含测试是否用它标记。
参数 | |
---|---|
annotation | String |
添加包含过滤器
public void addIncludeFilter (String filter)
添加要包含的测试的过滤器。
参数 | |
---|---|
filter | String |
清除排除注释
public void clearExcludeAnnotations ()
删除当前跟踪的所有排除注释。
清除排除过滤器
public void clearExcludeFilters ()
删除当前跟踪的所有排除过滤器。
清除包含注释
public void clearIncludeAnnotations ()
删除当前跟踪的所有包含注释。
清除包含过滤器
public void clearIncludeFilters ()
删除当前跟踪的所有包含过滤器。
测试用例数
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 |
仅设置收集测试
public void setCollectTestsOnly (boolean shouldCollectTest)
启用或禁用测试收集模式