HostTest
public
class
HostTest
extends Object
implements
IAbiReceiver,
IBuildReceiver,
IConfigurationReceiver,
IDeviceTest,
IDiscoverTestClasses,
IRemoteTest,
IRuntimeHintProvider,
IShardableTest,
ITestAnnotationFilterReceiver,
ITestCollector,
ITestFilterReceiver
| java.lang.Object | |
| ↳ | com.android.tradefed.testtype.HostTest |
适用于基于 JUnit 主机的测试的测试运行程序。如果要运行的测试实现了 IDeviceTest,此运行程序将传递对设备的引用。
摘要
字段 | |
|---|---|
public
static
final
String |
SET_OPTION_DESC
|
public
static
final
String |
SET_OPTION_NAME
|
公共构造函数 | |
|---|---|
HostTest()
|
|
公共方法 | |
|---|---|
void
|
addAllExcludeAnnotation(
添加了要排除的注解的 |
void
|
addAllExcludeFilters(
添加了要排除的测试的过滤条件的 |
void
|
addAllIncludeAnnotation(
添加了 |
void
|
addAllIncludeFilters(
添加要包含的测试的过滤条件的 |
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()
返回测试所涵盖的所有类中的测试用例数量 |
IAbi
|
getAbi()
|
|
getClassNames()
|
ITestDevice
|
getDevice()
获取被测设备。 |
|
getExcludeAnnotations()
返回要排除的注释的当前 |
|
getExcludeFilters()
返回排除过滤条件的当前 |
|
getIncludeAnnotations()
返回要包含的注释的当前 |
|
getIncludeFilters()
返回包含过滤条件的当前 |
long
|
getRuntimeHint()
返回测试的预期运行时(以毫秒为单位)。 |
void
|
run(TestInformation testInfo, ITestInvocationListener listener)
运行测试并向监听器报告结果。 |
void
|
setAbi(IAbi abi)
|
void
|
setBuild(IBuildInfo buildInfo)
|
void
|
setCollectTestsOnly(boolean shouldCollectTest)
启用或停用测试集合模式 |
void
|
setConfiguration(IConfiguration configuration)
注入正在使用的 |
void
|
setDevice(ITestDevice device)
注入被测设备。 |
static
void
|
setOptionToLoadedObject(Object testObj,
一种辅助程序,供设备运行程序使用,以便通过 set-option 以与 HostTest 相同的方式设置选项。 |
void
|
setTestInformation(TestInformation testInfo)
|
|
split(Integer shardCount, TestInformation testInfo)
我们会按测试类或方法拆分各个测试。 |
受保护的方法 | |
|---|---|
HostTest
|
createHostTest(Class<?> classObj)
用于在分片时创建 HostTest 实例的辅助程序。 |
IBuildInfo
|
getBuild()
获取 HostTest 收到的 build 信息。 |
ClassLoader
|
getClassLoader()
返回默认的类加载器。 |
final
|
getClasses()
|
File
|
getJarFile(String jarName, TestInformation testInfo)
检查通常用于不同用例的多个工件位置,以查找我们的 jar。 |
boolean
|
hasJUnit4Annotation(Class<?> classObj)
用于确定我们是否处理的是带有 Junit4 注解的测试类的帮助程序。 |
Object
|
loadObject(Class<?> classObj)
加载类对象并设置测试信息(设备、build)。 |
void
|
setClassName(String className)
清除,然后设置要运行的类名称。 |
boolean
|
shouldTestRun(AnnotatedElement annotatedElement)
检查是否有带注解的元素通过了过滤条件。 |
字段
SET_OPTION_DESC
public static final String SET_OPTION_DESC
SET_OPTION_NAME
public static final String SET_OPTION_NAME
公共构造函数
HostTest
public HostTest ()
公共方法
addAllExcludeAnnotation
public void addAllExcludeAnnotation (notAnnotations)
添加了要排除的注解的 ERROR(/Set),如果测试被标记为包含该注解,则会被排除。
| 参数 | |
|---|---|
notAnnotations |
|
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 notAnnotation)
添加了注解,以便在测试被标记为要排除时进行排除。
| 参数 | |
|---|---|
notAnnotation |
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 ()
删除当前跟踪的所有包含过滤条件。
countTestCases
public int countTestCases ()
返回测试中所有类的测试用例数量
| 返回 | |
|---|---|
int |
|
getClassNames
publicgetClassNames ()
| 返回 | |
|---|---|
|
|
getRuntimeHint
public long getRuntimeHint ()
返回测试的预期运行时(以毫秒为单位)。 该时间用于对分片执行进行负载均衡
| 返回 | |
|---|---|
long |
|
得分
public void run (TestInformation testInfo, ITestInvocationListener listener)
运行测试并向监听器报告结果。
| 参数 | |
|---|---|
testInfo |
TestInformation:包含运行测试的实用信息的 TestInformation 对象。 |
listener |
ITestInvocationListener:测试结果的 ITestInvocationListener |
| 抛出 | |
|---|---|
DeviceNotAvailableException |
|
setCollectTestsOnly
public void setCollectTestsOnly (boolean shouldCollectTest)
启用或停用测试集合模式
setConfiguration
public void setConfiguration (IConfiguration configuration)
注入正在使用的 IConfiguration。
| 参数 | |
|---|---|
configuration |
IConfiguration |
setOptionToLoadedObject
public static void setOptionToLoadedObject (Object testObj,
keyValueOptions) 一种辅助程序,供设备运行程序使用,以便通过 set-option 以与 HostTest 相同的方式设置选项。
| 参数 | |
|---|---|
testObj |
Object:将接收选项的对象。 |
keyValueOptions |
:格式为 HostTest set-option 所需的选项列表。 |
setTestInformation
public void setTestInformation (TestInformation testInfo)
| 参数 | |
|---|---|
testInfo |
TestInformation |
分解
publicsplit (Integer shardCount, TestInformation testInfo)
我们会按测试类或方法拆分各个测试。
| 参数 | |
|---|---|
shardCount |
Integer:尝试的分片数。 |
testInfo |
TestInformation:父级 TestInformation |
| 返回 | |
|---|---|
|
要单独执行的一组子测试,如果测试目前不可分片,则为 null |
受保护的方法
createHostTest
protected HostTest createHostTest (Class<?> classObj)
用于在分片时创建 HostTest 实例的辅助程序。替换为从 HostTest 返回任何子项。
| 参数 | |
|---|---|
classObj |
Class |
| 返回 | |
|---|---|
HostTest |
|
getClassLoader
protected ClassLoader getClassLoader ()
返回默认的类加载器。
| 返回 | |
|---|---|
ClassLoader |
|
getClasses
protected finalgetClasses ()
| 返回 | |
|---|---|
|
|
getJarFile
protected File getJarFile (String jarName,
TestInformation testInfo)检查不同用例的多个工件通常位于的位置,以查找我们的 jar。
| 参数 | |
|---|---|
jarName |
String |
testInfo |
TestInformation |
| 返回 | |
|---|---|
File |
|
hasJUnit4Annotation
protected boolean hasJUnit4Annotation (Class<?> classObj)
用于确定我们是否处理的是带有 Junit4 注解的测试类的帮助程序。
| 参数 | |
|---|---|
classObj |
Class |
| 返回 | |
|---|---|
boolean |
|
loadObject
protected Object loadObject (Class<?> classObj)
加载类对象并设置测试信息(设备、build)。
| 参数 | |
|---|---|
classObj |
Class |
| 返回 | |
|---|---|
Object |
|
setClassName
protected void setClassName (String className)
清除,然后设置要运行的类名称。
| 参数 | |
|---|---|
className |
String |
shouldTestRun
protected boolean shouldTestRun (AnnotatedElement annotatedElement)
检查是否有带注解的元素通过了过滤条件。公开以进行单元测试。
| 返回 | |
|---|---|
boolean |
如果测试不应运行,则为 false。 |