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 在给定设备上运行插桩测试软件包的测试。
摘要
字段 | |
|---|---|
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
用于在设备端启用新 |
public
static
final
String |
USE_TEST_STORAGE_SERVICE
|
公共构造函数 | |
|---|---|
AndroidJUnitTest()
|
|
公共方法 | |
|---|---|
void
|
addAllExcludeAnnotation(
添加了 |
void
|
addAllExcludeFilters(
添加了要排除的测试的过滤条件的 |
void
|
addAllIncludeAnnotation(
添加了 |
void
|
addAllIncludeFilters(
添加要包含的测试的过滤条件的 |
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()
返回要排除的注释的当前 |
|
getExcludeFilters()
返回排除过滤条件的当前 |
File
|
getExcludeTestFile()
返回包含已排除测试的文件。 |
|
getIncludeAnnotations()
返回要包含的注释的当前 |
|
getIncludeFilters()
返回包含过滤条件的当前 |
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)
|
受保护的方法 | |
|---|---|
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
公共构造函数
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 ()
删除当前跟踪的所有包含过滤条件。
getExcludeTestFile
public File getExcludeTestFile ()
返回包含已排除测试的文件。
| 返回 | |
|---|---|
File |
|
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 |
分解
publicsplit (int shardCount)
split() 的替代版本,还提供尝试运行的分片数量。这对于有时无法任意做出决定的一些测试运行程序非常有用。
| 参数 | |
|---|---|
shardCount |
int:尝试的分片数。 |
| 返回 | |
|---|---|
|
要单独执行的一组子测试,如果测试目前不可分片,则为 null |
受保护的方法
setRunnerArgs
protected void setRunnerArgs (IRemoteAndroidTestRunner runner)
| 参数 | |
|---|---|
runner |
IRemoteAndroidTestRunner |