InvocationExecution
public
class
InvocationExecution
extends Object
implements
IInvocationExecution
| java.lang.Object | |
| ↳ | com.android.tradefed.invoker.InvocationExecution |
用于描述所有调用步骤的类:build download、target_prep、run tests、clean up。
可扩展以替换某些步骤的默认行为。步骤的顺序由 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 cleanUp 步骤。 |
void
|
doSetup(TestInformation testInfo, IConfiguration config, ITestLogger listener)
执行 target_preparer 和 multi_target_preparer setUp 步骤。 |
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 版本。 |
|
getPreparersToRun(IConfiguration config, String deviceName)
检索要在此设备上运行的准备程序的列表。 |
void
|
logHostAdb(IConfiguration config, ITestLogger logger)
从 $TMPDIR/adb.$UID.log 收集日志。 |
void
|
runPreparersSetup(TestInformation testInfo, IConfiguration config, ITestLogger listener)
|
Throwable
|
runPreparersTearDown(TestInformation testInfo, ITestDevice device, String deviceName, int deviceIndex, ITestLogger logger, Throwable exception,
|
void
|
setTestTag(IBuildInfo info, IConfiguration config)
处理在 build 信息上设置测试标记。 |
字段
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
公共构造函数
InvocationExecution
public InvocationExecution ()
公共方法
cleanUpBuilds
public void cleanUpBuilds (IInvocationContext context,
IConfiguration config)执行 build_provider 清理步骤。与 build 提取相关。
| 参数 | |
|---|---|
context |
IInvocationContext:调用的 IInvocationContext。 |
config |
IConfiguration:此测试运行的 IConfiguration。 |
doCleanUp
public void doCleanUp (IInvocationContext context,
IConfiguration config,
Throwable exception)执行 target_preparer 和 multi_target_preparer cleanUp 步骤。设备是否已清理。
| 参数 | |
|---|---|
context |
IInvocationContext:调用的 IInvocationContext。 |
config |
IConfiguration:此测试运行的 IConfiguration。 |
exception |
Throwable:测试运行时抛出的原始异常。 |
doSetup
public void doSetup (TestInformation testInfo,
IConfiguration config,
ITestLogger listener)执行 target_preparer 和 multi_target_preparer setUp 步骤。是否已完成运行测试所需的所有设备设置。
| 参数 | |
|---|---|
testInfo |
TestInformation:调用的 TestInformation。 |
config |
IConfiguration:此测试运行的 IConfiguration。 |
listener |
ITestLogger:用于报告设置失败日志的 ITestLogger。 |
| 抛出 | |
|---|---|
BuildError |
|
DeviceNotAvailableException |
|
TargetSetupError |
|
doTeardown
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:测试运行时抛出的原始异常。 |
fetchBuild
public boolean fetchBuild (TestInformation testInfo,
IConfiguration config,
IRescheduler rescheduler,
ITestInvocationListener listener)执行调用的 build_provider 步骤。
| 参数 | |
|---|---|
testInfo |
TestInformation:调用的 TestInformation。 |
config |
IConfiguration:此测试运行的 IConfiguration。 |
rescheduler |
IRescheduler:IRescheduler,用于重新调度调用的部分,以便在其他资源上执行 |
listener |
ITestInvocationListener:用于报告 build 下载失败的 ITestInvocation。 |
| 返回 | |
|---|---|
boolean |
如果成功下载 build,则为 true;否则为 false。 |
| 抛出 | |
|---|---|
BuildRetrievalError |
|
DeviceNotAvailableException |
|
reportLogs
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 |
|
runTests
public void runTests (TestInformation info,
IConfiguration config,
ITestInvocationListener listener)运行测试。
| 参数 | |
|---|---|
info |
TestInformation:用于运行测试的 TestInformation。 |
config |
IConfiguration:要运行的 IConfiguration |
listener |
ITestInvocationListener:测试结果的 ITestInvocationListener |
shardConfig
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 |
如果测试已分片,则为 true。否则返回 false
|
受保护的方法
collectAutoInfo
protected void collectAutoInfo (IConfiguration config, TestInformation info)
自动收集有关主要被测设备的一些信息。
| 参数 | |
|---|---|
config |
IConfiguration |
info |
TestInformation |
| 抛出 | |
|---|---|
DeviceNotAvailableException |
|
createShardHelper
protected IShardHelper createShardHelper ()
创建并返回要使用的 IShardHelper。
| 返回 | |
|---|---|
IShardHelper |
|
customizeDevicePreInvocation
protected void customizeDevicePreInvocation (IConfiguration config, IInvocationContext context)
在 preInvocationSetup 之前,提供自定义部分设备的机会。
| 参数 | |
|---|---|
config |
IConfiguration:调用的配置。 |
context |
IInvocationContext:当前的调用上下文。 |
getAdbVersion
protected String getAdbVersion ()
返回调用所用的 adb 版本。
| 返回 | |
|---|---|
String |
|
getPreparersToRun
protectedgetPreparersToRun (IConfiguration config, String deviceName)
检索要在此设备上运行的准备程序的列表。
在沙盒类中被替换,以限制在沙盒子级中运行实验准备程序
| 参数 | |
|---|---|
config |
IConfiguration |
deviceName |
String |
| 返回 | |
|---|---|
|
|
logHostAdb
protected void logHostAdb (IConfiguration config, ITestLogger logger)
从 $TMPDIR/adb.$UID.log 收集日志。
| 参数 | |
|---|---|
config |
IConfiguration |
logger |
ITestLogger |
runPreparersSetup
protected void runPreparersSetup (TestInformation testInfo,
IConfiguration config,
ITestLogger listener)| 参数 | |
|---|---|
testInfo |
TestInformation |
config |
IConfiguration |
listener |
ITestLogger |
| 抛出 | |
|---|---|
BuildError |
|
DeviceNotAvailableException |
|
TargetSetupError |
|
runPreparersTearDown
protected Throwable runPreparersTearDown (TestInformation testInfo,
ITestDevice device,
String deviceName,
int deviceIndex,
ITestLogger logger,
Throwable exception,
preparersToRun) | 参数 | |
|---|---|
testInfo |
TestInformation |
device |
ITestDevice |
deviceName |
String |
deviceIndex |
int |
logger |
ITestLogger |
exception |
Throwable |
preparersToRun |
|
| 返回 | |
|---|---|
Throwable |
|
setTestTag
protected void setTestTag (IBuildInfo info,
IConfiguration config)处理在 build 信息上设置测试标记。
| 参数 | |
|---|---|
info |
IBuildInfo |
config |
IConfiguration |