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(Set<String> excludeAnnotations)

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

void addAllExcludeFilters(Set<String> filters)

添加用于指定要排除哪些测试的过滤条件Set

void addAllIncludeAnnotation(Set<String> annotations)

添加一个注解 Set,如果测试标记了该注解,则包含该注解。

void addAllIncludeFilters(Set<String> filters)

添加用于指定要包含哪些测试的过滤条件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()

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

Set<String> getExcludeAnnotations()

返回要排除的注释的当前 Set

Set<String> getExcludeFilters()

返回当前的排除过滤条件Set

File getExcludeTestFile()

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

Set<String> getIncludeAnnotations()

返回要包含的注释的当前 Set

Set<String> getIncludeFilters()

返回当前的包含过滤条件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)

设置包含的测试文件。

Collection<IRemoteTest> 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 (Set<String> excludeAnnotations)

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

参数
excludeAnnotations Set

addAllExcludeFilters

public void addAllExcludeFilters (Set<String> filters)

添加用于指定要排除哪些测试的过滤条件Set

参数
filters Set

addAllIncludeAnnotation

public void addAllIncludeAnnotation (Set<String> annotations)

添加一个注解 Set 列表,如果测试标记了这些注解,则包含这些测试。

参数
annotations Set

addAllIncludeFilters

public void addAllIncludeFilters (Set<String> filters)

添加用于指定要包含哪些测试的过滤条件Set

参数
filters Set

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 Set<String> getExcludeAnnotations ()

返回当前要排除的注释的 Set

返回
Set<String>

getExcludeFilters

public Set<String> getExcludeFilters ()

返回当前的排除过滤条件Set

返回
Set<String>

getExcludeTestFile

public File getExcludeTestFile ()

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

返回
File

getIncludeAnnotations

public Set<String> getIncludeAnnotations ()

返回要包含的注释的当前 Set

返回
Set<String>

getIncludeFilters

public Set<String> getIncludeFilters ()

返回当前的包含过滤条件Set

返回
Set<String>

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

run

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 Collection<IRemoteTest> split (int shardCount)

split() 的替代版本,还提供尝试运行的 shardCount。这对于有时无法任意决定的某些测试运行程序非常有用。

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

返回
Collection<IRemoteTest> 要单独执行的子测试集合,如果测试目前无法分片,则为 null

受保护的方法

setRunnerArgs

protected void setRunnerArgs (IRemoteAndroidTestRunner runner)

参数
runner IRemoteAndroidTestRunner