AndroidJ单元测试

public class AndroidJUnitTest
extends InstrumentationTest implements IRuntimeHintProvider , ITestFileFilterReceiver , ITestFilterReceiver , ITestAnnotationFilterReceiver , IShardableTest

java.lang.Object
com.android.tradefed.testtype.InstrumentationTest
com.android.tradefed.testtype.AndroidJUnitTest


使用 android.support.test.runner.AndroidJUnitRunner 在给定设备上运行仪器测试包的测试。

概括

领域

public static final String EXCLUDE_COLLECTOR_FILTER_KEY

public static final String INCLUDE_COLLECTOR_FILTER_KEY

来自收集器端帮助程序库的选项。

public static final String NEW_RUN_LISTENER_ORDER_KEY

用于在设备端启用新的RunListener顺序的仪器测试运行器参数。

public static final String USE_TEST_STORAGE_SERVICE

公共构造函数

AndroidJUnitTest ()

公共方法

void addAllExcludeAnnotation ( excludeAnnotations) addAllExcludeAnnotation ( excludeAnnotations)

添加一个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 excludeAnnotation)

添加注释以排除是否测试是否用它标记。

void addExcludeFilter (String filter)

添加要排除哪些测试的过滤器。

void addIncludeAnnotation (String annotation)

添加一个注释以包含如果一个测试是否用它标记。

void addIncludeFilter (String filter)

添加要包含哪些测试的过滤器。

void clearExcludeAnnotations ()

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

void clearExcludeFilters ()

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

void clearIncludeAnnotations ()

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

void clearIncludeFilters ()

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

getExcludeAnnotations ()

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

getExcludeFilters ()

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

File getExcludeTestFile ()

返回包含排除测试的文件。

getIncludeAnnotations ()

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

getIncludeFilters ()

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

File getIncludeTestFile ()

返回包含包含的测试的文件。

long getRuntimeHint ()

以毫秒为单位返回测试的预期运行时间。

boolean isClassOrMethod (String filter)

如果字符串是类或方法的名称,则返回。

boolean isRegex (String filter)

如果字符串是过滤器的正则表达式,则返回。

void run ( TestInformation testInfo, ITestInvocationListener listener)

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

void setExcludeTestFile (File testFile)

设置排除的测试文件。

void setIncludeTestFile (File testFile)

设置包含的测试文件。

split (int shardCount)

split()的替代版本,它还提供尝试运行的 shardCount。

受保护的方法

void setRunnerArgs (IRemoteAndroidTestRunner runner)

领域

EXCLUDE_COLLECTOR_FILTER_KEY

public static final String EXCLUDE_COLLECTOR_FILTER_KEY

INCLUDE_COLLECTOR_FILTER_KEY

public static final String INCLUDE_COLLECTOR_FILTER_KEY

来自收集器端帮助程序库的选项。

NEW_RUN_LISTENER_ORDER_KEY

public static final String NEW_RUN_LISTENER_ORDER_KEY

用于在设备端启用新的RunListener顺序的仪器测试运行器参数。

USE_TEST_STORAGE_SERVICE

public static final String USE_TEST_STORAGE_SERVICE

公共构造函数

AndroidJ单元测试

public AndroidJUnitTest ()

公共方法

添加所有排除注释

public void addAllExcludeAnnotation ( excludeAnnotations)

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

参数
excludeAnnotations

添加所有排除过滤器

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

添加注释以排除是否测试是否用它标记。

参数
excludeAnnotation 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 ()

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

getExcludeAnnotations

public  getExcludeAnnotations ()

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

退货

获取排除过滤器

public  getExcludeFilters ()

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

退货

获取排除测试文件

public File getExcludeTestFile ()

返回包含排除测试的文件。

退货
File

getIncludeAnnotations

public  getIncludeAnnotations ()

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

退货

getIncludeFilters

public  getIncludeFilters ()

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

退货

获取包含测试文件

public File getIncludeTestFile ()

返回包含包含的测试的文件。

退货
File

获取运行时提示

public long getRuntimeHint ()

以毫秒为单位返回测试的预期运行时间。该时间用于负载平衡分片执行

退货
long

isClassOrMethod

public boolean isClassOrMethod (String filter)

如果字符串是类或方法的名称,则返回。

参数
filter String

退货
boolean

正则表达式

public boolean isRegex (String filter)

如果字符串是过滤器的正则表达式,则返回。

参数
filter String

退货
boolean

跑步

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

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

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

listener ITestInvocationListener : 测试结果的ITestInvocationListener

投掷
DeviceNotAvailableException

设置排除测试文件

public void setExcludeTestFile (File testFile)

设置排除的测试文件。不确保 testFile 存在或者是一个文件。

参数
testFile File

设置包含测试文件

public void setIncludeTestFile (File testFile)

设置包含的测试文件。不确保 testFile 存在或者是一个文件。

参数
testFile File

分裂

public  split (int shardCount)

split()的替代版本,它还提供尝试运行的 shardCount。这对于某些有时不能随意决定的测试运行器很有用。

参数
shardCount int :尝试的分片数。

退货
要单独执行的子测试的集合,如果测试当前不可分片则为null

受保护的方法

setRunnerArgs

protected void setRunnerArgs (IRemoteAndroidTestRunner runner)

参数
runner IRemoteAndroidTestRunner