AndroidJUnitTest

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

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


一种测试,用于使用 android.support.test.runner.AndroidJUnitRunner 在给定设备上运行插桩测试软件包。

摘要

常量

String EXCLUDE_COLLECTOR_FILTER_KEY

String INCLUDE_COLLECTOR_FILTER_KEY

收集器端辅助程序库中的选项。

String NEW_RUN_LISTENER_ORDER_KEY

用于在设备端启用新的 RunListener 顺序的插桩测试运行程序实参。

String USE_TEST_STORAGE_SERVICE

公共构造函数

AndroidJUnitTest()

公共方法

void addAllExcludeAnnotation( excludeAnnotations)

添加了 ERROR(/Set) 注解,如果测试标记了该注解,则排除相应测试。

void addAllExcludeFilters( filters)

添加了要排除的测试的过滤条件的 ERROR(/Set)

void addAllIncludeAnnotation( annotations)

添加了 ERROR(/Set) 注释,用于指定如果测试标记了该注释,则包含该注释。

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

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

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

常量值: “exclude-filter-group”

INCLUDE_COLLECTOR_FILTER_KEY

public static final String INCLUDE_COLLECTOR_FILTER_KEY

收集器端辅助库中的选项。

常量值: “include-filter-group”

NEW_RUN_LISTENER_ORDER_KEY

public static final String NEW_RUN_LISTENER_ORDER_KEY

用于在设备端启用新的 RunListener 顺序的插桩测试运行程序实参。

常量值: “newRunListenerMode”

USE_TEST_STORAGE_SERVICE

public static final String USE_TEST_STORAGE_SERVICE

常量值: "useTestStorageService"

公共构造函数

AndroidJUnitTest

public AndroidJUnitTest ()

公共方法

addAllExcludeAnnotation

public void addAllExcludeAnnotation ( excludeAnnotations)

添加了 ERROR(/Set) 注解,如果测试标记了该注解,则排除相应测试。

参数
excludeAnnotations

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

添加了一个注解,用于排除标记了该注解的测试。

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

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

getExcludeAnnotations

public  getExcludeAnnotations ()

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

返回

getExcludeFilters

public  getExcludeFilters ()

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

返回

getExcludeTestFile

public File getExcludeTestFile ()

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

返回
File

getIncludeAnnotations

public  getIncludeAnnotations ()

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

返回

getIncludeFilters

public  getIncludeFilters ()

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

返回

getIncludeTestFile

public File getIncludeTestFile ()

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

返回
File

getRuntimeHint

public long getRuntimeHint ()

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

返回
long

isClassOrMethod

public boolean isClassOrMethod (String filter)

返回字符串是否为类或方法的名称。

参数
filter String

返回
boolean

isParameterizedTest

public boolean isParameterizedTest (String filter)

返回字符串是否为参数化测试。

参数
filter String

返回
boolean

isRegex

public boolean isRegex (String filter)

返回字符串是否为过滤条件的正则表达式。

参数
filter String

返回
boolean

得分

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

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

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

listener ITestInvocationListener:测试结果的 ITestInvocationListener

抛出
DeviceNotAvailableException

setExcludeTestFile

public void setExcludeTestFile (File testFile)

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

参数
testFile File

setIncludeTestFile

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