ITargetPreparer

public interface ITargetPreparer
implements IDisableable

com.android.tradefed.targetprep.ITargetPreparer


为运行测试的测试环境做好准备。

例如,安装软件、出于测试目的调整环境设置、启动目标等。

请注意,可以在一个配置中指定多个 ITargetPreparer。建议每个 ITargetPreparer 清楚地记录其设置前和设置后预期的环境。例如,配置设备以进行测试的 ITargetPreparer 必须在安装软件的 ITargetPreparer 之后运行。

摘要

公共方法

default void setUp(ITestDevice device, IBuildInfo buildInfo)

此方法已废弃。 改用 setUp(com.android.tradefed.invoker.TestInformation)

default void setUp(TestInformation testInformation)

执行目标设置以进行测试。

default void tearDown(TestInformation testInformation, Throwable e)

在测试后执行目标清理/拆解。

default void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)

此方法已废弃。 改用 tearDown(com.android.tradefed.invoker.TestInformation, Throwable)

公共方法

设置

public void setUp (ITestDevice device, 
                IBuildInfo buildInfo)

此方法已废弃。
改用 setUp(com.android.tradefed.invoker.TestInformation)

执行目标设置以进行测试。

参数
device ITestDevice:要准备的 ITestDevice

buildInfo IBuildInfo:被测 build 的相关数据。

抛出
TargetSetupError 设置环境发生严重错误时发出通知
BuildError 如果发生与 BuildInfo 相关的错误
DeviceNotAvailableException 如果设备无响应

设置

public void setUp (TestInformation testInformation)

执行目标设置以进行测试。

参数
testInformation TestInformation:调用的 TestInformation

抛出
TargetSetupError 设置环境发生严重错误时发出通知
BuildError 如果由于准备构建而发生错误
DeviceNotAvailableException 如果设备无响应

拆解

public void tearDown (TestInformation testInformation, 
                Throwable e)

测试后执行目标清理/拆解。

参数
testInformation TestInformation:调用的 TestInformation

e Throwable:如果调用因异常而结束,这将成为在调用级别捕获的异常。否则,将为 null

抛出
DeviceNotAvailableException 如果设备无响应

拆解

public void tearDown (ITestDevice device, 
                IBuildInfo buildInfo, 
                Throwable e)

此方法已废弃。
改用 tearDown(com.android.tradefed.invoker.TestInformation, Throwable)

测试后执行目标清理/拆解。

参数
device ITestDevice:要准备的 ITestDevice

buildInfo IBuildInfo:被测 build 的相关数据。

e Throwable:如果调用因异常而结束,这将成为在调用级别捕获的异常。否则,将为 null

抛出
DeviceNotAvailableException 如果设备无响应