调用执行
public class InvocationExecution
extends Object
implements IInvocationExecution
java.lang.Object | |
↳ | com.android.tradefed.invoker.InvocationExecution |
描述所有调用步骤的类:构建下载、target_prep、运行测试、清理。可以扩展以覆盖某些步骤的默认行为。步骤的顺序由TestInvocation
驱动。
概括
领域 | |
---|---|
public static final String | ADB_VERSION_KEY |
public static final String | JAVA_CLASSPATH_KEY |
public static final String | JAVA_VERSION_KEY
|
公共构造函数 | |
---|---|
InvocationExecution () |
公共方法 | |
---|---|
void | cleanUpBuilds ( IInvocationContext context, IConfiguration config) 执行 build_provider 清理步骤。 |
void | doCleanUp ( IInvocationContext context, IConfiguration config, Throwable exception) 执行 target_preparer 和 multi_target_preparer 清理步骤。 |
void | doSetup ( TestInformation testInfo, IConfiguration config, ITestLogger listener) 执行 target_preparer 和 multi_target_preparer 设置步骤。 |
void | doTeardown ( TestInformation testInfo, IConfiguration config, ITestLogger logger, Throwable exception) 执行 target_preparer 和 multi_target_preparer 拆卸步骤。 |
boolean | fetchBuild ( TestInformation testInfo, IConfiguration config, IRescheduler rescheduler, ITestInvocationListener listener) 执行调用的 build_provider 步骤。 |
void | reportLogs ( ITestDevice device, ITestLogger listener, TestInvocation.Stage stage) 在调用的不同阶段报告一些设备日志。 |
void | runDevicePostInvocationTearDown ( IInvocationContext context, IConfiguration config, Throwable exception) 为调用的每个设备部分调用 |
void | runDevicePreInvocationSetup ( IInvocationContext context, IConfiguration config, ITestLogger logger) |
void | runTests ( TestInformation info, IConfiguration config, ITestInvocationListener listener) 运行测试。 |
boolean | shardConfig ( IConfiguration config, TestInformation testInfo, IRescheduler rescheduler, ITestLogger logger) 尝试将配置分片成子配置,重新安排在多个资源上并行运行。 |
受保护的方法 | |
---|---|
void | collectAutoInfo ( IConfiguration config, TestInformation info) 自动收集有关被测主设备的一些信息。 |
IShardHelper | createShardHelper () 创建返回要使用的 |
void | customizeDevicePreInvocation ( IConfiguration config, IInvocationContext context) 在 preInvocationSetup 之前给一些自定义设备的机会。 |
String | getAdbVersion () 返回用于调用的 adb 版本。 |
getLabPreparersToRun ( IConfiguration config, String deviceName) 检索要在此设备上运行的实验室准备者列表。 | |
getTargetPreparersToRun ( IConfiguration config, String deviceName) 检索要在此设备上运行的目标准备程序列表。 | |
void | logHostAdb ( IConfiguration config, ITestLogger logger) 从 $TMPDIR/adb.$UID.log 收集日志。 |
Throwable | runPreparersTearDown ( TestInformation testInfo, ITestDevice device, String deviceName, int deviceIndex, ITestLogger logger, Throwable exception, preparersToRun, trackPreparersMap) runPreparersTearDown ( TestInformation testInfo, ITestDevice device, String deviceName, int deviceIndex, ITestLogger logger, Throwable exception, preparersToRun, trackPreparersMap) runPreparersTearDown ( TestInformation testInfo, ITestDevice device, String deviceName, int deviceIndex, ITestLogger logger, Throwable exception, preparersToRun, trackPreparersMap) |
void | setTestTag ( IBuildInfo info, IConfiguration config) 处理在构建信息上设置测试标签。 |
领域
ADB_VERSION_KEY
public static final String ADB_VERSION_KEY
JAVA_CLASSPATH_KEY
public static final String JAVA_CLASSPATH_KEY
JAVA_VERSION_KEY
public static final String JAVA_VERSION_KEY
公共构造函数
调用执行
public InvocationExecution ()
公共方法
清理构建
public void cleanUpBuilds (IInvocationContext context, IConfiguration config)
执行 build_provider 清理步骤。与构建获取相关联。
参数 | |
---|---|
context | IInvocationContext :调用的IInvocationContext 。 |
config | IConfiguration :本次测试运行的IConfiguration 。 |
清理
public void doCleanUp (IInvocationContext context, IConfiguration config, Throwable exception)
执行 target_preparer 和 multi_target_preparer 清理步骤。设备是否清理。
参数 | |
---|---|
context | IInvocationContext :调用的IInvocationContext 。 |
config | IConfiguration :本次测试运行的IConfiguration 。 |
exception | Throwable :测试运行时抛出的原始异常。 |
设置
public void doSetup (TestInformation testInfo, IConfiguration config, ITestLogger listener)
执行 target_preparer 和 multi_target_preparer 设置步骤。是否设置了测试运行所需的所有设备。
参数 | |
---|---|
testInfo | TestInformation :调用的TestInformation 。 |
config | IConfiguration :本次测试运行的IConfiguration 。 |
listener | ITestLogger :用于报告设置失败日志的ITestLogger 。 |
投掷 | |
---|---|
BuildError | |
DeviceNotAvailableException | |
TargetSetupError |
拆解
public void doTeardown (TestInformation testInfo, IConfiguration config, ITestLogger logger, Throwable exception)
执行 target_preparer 和 multi_target_preparer 拆卸步骤。设备是否拆卸与设置相关。
参数 | |
---|---|
testInfo | TestInformation :调用的TestInformation 。 |
config | IConfiguration :本次测试运行的IConfiguration 。 |
logger | ITestLogger :用于报告日志的ITestLogger 。 |
exception | Throwable :测试运行时抛出的原始异常。 |
获取构建
public boolean fetchBuild (TestInformation testInfo, IConfiguration config, IRescheduler rescheduler, ITestInvocationListener listener)
执行调用的 build_provider 步骤。
参数 | |
---|---|
testInfo | TestInformation :调用的TestInformation 。 |
config | IConfiguration :本次测试运行的IConfiguration 。 |
rescheduler | IRescheduler : IRescheduler ,用于重新安排调用的一部分以在另一个资源上执行 |
listener | ITestInvocationListener :报告构建下载失败的ITestInvocation 。 |
退货 | |
---|---|
boolean | 如果我们成功下载构建,则为真,否则为假。 |
投掷 | |
---|---|
BuildRetrievalError | |
DeviceNotAvailableException |
报告日志
public void reportLogs (ITestDevice device, ITestLogger listener, TestInvocation.Stage stage)
在调用的不同阶段报告一些设备日志。例如:logcat。
参数 | |
---|---|
device | ITestDevice :要从中报告日志的设备。 |
listener | ITestLogger :日志的记录器。 |
stage | TestInvocation.Stage :我们所处的调用阶段。 |
runDevicePostInvocationTearDown
public void runDevicePostInvocationTearDown (IInvocationContext context, IConfiguration config, Throwable exception)
为调用的每个设备部分调用ITestDevice#postInvocationTearDown(Throwable)
。
参数 | |
---|---|
context | IInvocationContext :调用的IInvocationContext 。 |
config | IConfiguration :本次测试运行的IConfiguration 。 |
exception | Throwable :测试运行时抛出的原始异常(如果有)。 |
runDevicePreInvocationSetup
public void runDevicePreInvocationSetup (IInvocationContext context, IConfiguration config, ITestLogger logger)
参数 | |
---|---|
context | IInvocationContext :调用的IInvocationContext 。 |
config | IConfiguration :本次测试运行的IConfiguration 。 |
logger | ITestLogger :用于报告日志的ITestLogger 。 |
投掷 | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
运行测试
public void runTests (TestInformation info, IConfiguration config, ITestInvocationListener listener)
运行测试。
参数 | |
---|---|
info | TestInformation :用于运行测试的TestInformation 。 |
config | IConfiguration :要运行的IConfiguration |
listener | ITestInvocationListener : 测试结果的ITestInvocationListener |
分片配置
public boolean shardConfig (IConfiguration config, TestInformation testInfo, IRescheduler rescheduler, ITestLogger logger)
尝试将配置分片成子配置,重新安排在多个资源上并行运行。
如果分片计数大于 1,它将通过设置分片索引并重新安排它们来简单地为每个分片创建配置。如果未设置分片计数,它将回退到IShardHelper#shardConfig
。
参数 | |
---|---|
config | IConfiguration :当前IConfiguration 。 |
testInfo | TestInformation :保存测试信息的TestInformation 。 |
rescheduler | IRescheduler : IRescheduler 。 |
logger | ITestLogger : ITestLogger 用于在分片期间记录文件。 |
退货 | |
---|---|
boolean | 如果测试被分片则为真。否则返回false |
受保护的方法
收集汽车信息
protected void collectAutoInfo (IConfiguration config, TestInformation info)
自动收集有关被测主设备的一些信息。
参数 | |
---|---|
config | IConfiguration |
info | TestInformation |
投掷 | |
---|---|
DeviceNotAvailableException |
自定义设备预调用
protected void customizeDevicePreInvocation (IConfiguration config, IInvocationContext context)
在 preInvocationSetup 之前给一些自定义设备的机会。
参数 | |
---|---|
config | IConfiguration :调用的配置。 |
context | IInvocationContext :当前调用上下文。 |
获取 Adb 版本
protected String getAdbVersion ()
返回用于调用的 adb 版本。
退货 | |
---|---|
String |
getLabPreparersToRun
protectedgetLabPreparersToRun (IConfiguration config, String deviceName)
检索要在此设备上运行的实验室准备者列表。
在沙盒类中覆盖以限制实验室准备者在沙盒子类中运行
参数 | |
---|---|
config | IConfiguration |
deviceName | String |
退货 | |
---|---|
getTargetPreparersToRun
protectedgetTargetPreparersToRun (IConfiguration config, String deviceName)
检索要在此设备上运行的目标准备程序列表。
在沙盒类中覆盖以限制实验室准备者在沙盒子类中运行
参数 | |
---|---|
config | IConfiguration |
deviceName | String |
退货 | |
---|---|
logHostAdb
protected void logHostAdb (IConfiguration config, ITestLogger logger)
从 $TMPDIR/adb.$UID.log 收集日志。
参数 | |
---|---|
config | IConfiguration |
logger | ITestLogger |
运行PreparersTearDown
protected Throwable runPreparersTearDown (TestInformation testInfo, ITestDevice device, String deviceName, int deviceIndex, ITestLogger logger, Throwable exception,preparersToRun, trackPreparersMap)
参数 | |
---|---|
testInfo | TestInformation |
device | ITestDevice |
deviceName | String |
deviceIndex | int |
logger | ITestLogger |
exception | Throwable |
preparersToRun | |
trackPreparersMap |
退货 | |
---|---|
Throwable |
设置测试标签
protected void setTestTag (IBuildInfo info, IConfiguration config)
处理在构建信息上设置测试标签。
参数 | |
---|---|
info | IBuildInfo |
config | IConfiguration |