设备测试用例

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 ),那么这非常有用

概括

领域

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)

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

void run ( TestInformation testInfo, ITestInvocationListener listener)

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

void setCollectTestsOnly (boolean shouldCollectTest)

启用或禁用测试收集模式

void setDevice ( ITestDevice device)

注入被测设备。

领域

mExcludeAnnotation

protected  mExcludeAnnotation

要运行的测试的排除注释

m排除过滤器

protected  mExcludeFilters

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

mIncludeAnnotation

protected  mIncludeAnnotation

包含要运行的测试的注释

m包含过滤器

protected  mIncludeFilters

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

公共构造函数

设备测试用例

public DeviceTestCase ()

设备测试用例

public DeviceTestCase (String name)

参数
name String

公共方法

添加全部排除注释

public void addAllExcludeAnnotation ( notAnnotations)

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

参数
notAnnotations

添加所有排除过滤器

public void addAllExcludeFilters ( filters)

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

参数
filters

添加全部包含注释

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

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

清除包含注释

public void clearIncludeAnnotations ()

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

清除包含过滤器

public void clearIncludeFilters ()

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

测试用例数

public int countTestCases ()

退货
int

获取设备

public ITestDevice getDevice ()

获取被测设备。

退货
ITestDevice ITestDevice

获取排除注释

public  getExcludeAnnotations ()

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

退货

获取排除过滤器

public  getExcludeFilters ()

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

退货

获取包含注释

public  getIncludeAnnotations ()

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

退货

获取包含过滤器

public  getIncludeFilters ()

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

退货

跑步

public void run (TestResult result)

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

JUnit 框架仅支持通过将 TestCase 包装在 TestSuite 中来运行 TestCase 中的所有测试。不幸的是,使用这种机制,调用者无法控制自己的测试用例的生命周期,这使得无法执行诸如让 tradefed 配置框架将选项注入测试用例之类的操作。

参数
result TestResult

跑步

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

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

参数
testInfo TestInformationTestInformation对象包含运行测试的有用信息。

listener ITestInvocationListener :测试结果的ITestInvocationListener

投掷
DeviceNotAvailableException

仅设置收集测试

public void setCollectTestsOnly (boolean shouldCollectTest)

启用或禁用测试收集模式

设置设备

public void setDevice (ITestDevice device)

注入被测设备。

参数
device ITestDevice :要使用的ITestDevice