设备测试用例

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


提供IRemoteTestIDeviceTest服务的 Helper JUnit 测试用例。

如果您想实施遵循定义测试的 JUnit 模式的测试,并且仍然完全支持其他 tradefed 功能(例如Option s),这将很有用

概括

领域

protected mExcludeAnnotation

要运行的测试的排除注释

protected mExcludeFilters

要运行的测试名称的排除过滤器

protected mIncludeAnnotation

要运行的测试的包含注释

protected mIncludeFilters

要运行的测试名称的包含过滤器

公共构造函数

DeviceTestCase ()
DeviceTestCase (String name)

公共方法

void addAllExcludeAnnotation ( notAnnotations) addAllExcludeAnnotation ( notAnnotations)

添加一个ERROR(/Set)注释以排除是否测试是否用它标记。

void addAllExcludeFilters ( filters) addAllExcludeFilters ( filters)

添加要排除的测试的过滤器的ERROR(/Set)

void addAllIncludeAnnotation ( annotations) addAllIncludeAnnotation ( annotations)

添加一个ERROR(/Set)注释以包含是否测试是否用它标记。

void addAllIncludeFilters ( filters) addAllIncludeFilters ( filters)

添加要包含哪些测试的过滤器的ERROR(/Set)

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 ()

返回要排除的注释的当前ERROR(/Set)

getExcludeFilters ()

返回排除过滤器的当前ERROR(/Set)

getIncludeAnnotations ()

返回要包含的注释的当前ERROR(/Set)

getIncludeFilters ()

返回包含过滤器的当前ERROR(/Set)

void run (TestResult result)

如果要运行的测试方法为空,则覆盖父方法以运行所有测试方法。

void run ( TestInformation testInfo, ITestInvocationListener listener)

运行测试,并将结果报告给侦听器。

void setCollectTestsOnly (boolean shouldCollectTest)

启用或禁用测试收集模式

void setDevice ( ITestDevice device)

注入被测设备。

领域

mExclude注解

protected  mExcludeAnnotation

要运行的测试的排除注释

mExcludeFilters

protected  mExcludeFilters

要运行的测试名称的排除过滤器

mIncludeAnnotation

protected  mIncludeAnnotation

要运行的测试的包含注释

mIncludeFilters

protected  mIncludeFilters

要运行的测试名称的包含过滤器

公共构造函数

设备测试用例

public DeviceTestCase ()

设备测试用例

public DeviceTestCase (String name)

参数
name String

公共方法

添加所有排除注释

public void addAllExcludeAnnotation ( notAnnotations)

添加一个ERROR(/Set)注释以排除是否测试是否用它标记。

参数
notAnnotations

添加所有排除过滤器

public void addAllExcludeFilters ( filters)

添加要排除的测试的过滤器的ERROR(/Set)

参数
filters

addAllIncludeAnnotation

public void addAllIncludeAnnotation ( annotations)

添加一个ERROR(/Set)注释以包含是否测试是否用它标记。

参数
annotations

添加所有包含过滤器

public void addAllIncludeFilters ( filters)

添加要包含哪些测试的过滤器的ERROR(/Set)

参数
filters

添加排除注解

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 ()

删除当前跟踪的所有排除过滤器。

clearIncludeAnnotations

public void clearIncludeAnnotations ()

删除当前跟踪的所有包含注释。

清除包含过滤器

public void clearIncludeFilters ()

删除当前跟踪的所有包含过滤器。

计数测试用例

public int countTestCases ()

退货
int

获取设备

public ITestDevice getDevice ()

获取待测设备。

退货
ITestDevice ITestDevice

getExcludeAnnotations

public  getExcludeAnnotations ()

返回要排除的注释的当前ERROR(/Set)

退货

获取排除过滤器

public  getExcludeFilters ()

返回排除过滤器的当前ERROR(/Set)

退货

getIncludeAnnotations

public  getIncludeAnnotations ()

返回要包含的注释的当前ERROR(/Set)

退货

getIncludeFilters

public  getIncludeFilters ()

返回包含过滤器的当前ERROR(/Set)

退货

跑步

public void run (TestResult result)

如果要运行的测试方法为空,则覆盖父方法以运行所有测试方法。

JUnit 框架仅支持通过将其包装在 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)

启用或禁用测试收集模式

设置设备

public void setDevice (ITestDevice device)

注入被测设备。

参数
device ITestDevice :要使用的ITestDevice