仪器测试

public class InstrumentationTest
extends Object implements IDeviceTest , IRemoteTest , ITestCollector , IAbiReceiver , IConfigurationReceiver , IMetricCollectorReceiver

java.lang.Object
com.android.tradefed.testtype.InstrumentationTest


在给定设备上运行仪器测试包的测试。

概括

字段

public static final String RUN_TESTS_AS_USER_KEY

public static final String RUN_TESTS_ON_SDK_SANDBOX

protected boolean mDebug

公共构造函数

InstrumentationTest ()

公共方法

void addDeviceListeners ( extraListeners) addDeviceListeners ( extraListeners)

允许向跑步者添加更多自定义侦听器

void addInstrumentationArg (String key, String value)

添加一个参数以在运行仪器测试时提供。

IAbi getAbi ()
IConfiguration getConfiguration ()

获取此测试的IConfiguration

String getCoverageTarget ()

获取之前通过setCoverageTarget(String)设置的 coverageTarget。

boolean getDebug ()

获取检测调试设置。

ITestDevice getDevice ()

获取待测设备。

String getForceAbi ()
long getMaxTimeout ()

返回为检测设置的最大超时。

String getPackageName ()

获取要运行的 Android 清单包。

String getRunName ()

获取将提供给侦听器的自定义测试运行名称

String getRunnerName ()

获取要使用的 Android 检测运行器。

void run ( TestInformation testInfo, ITestInvocationListener listener)

运行测试,并将结果报告给侦听器。

void setAbi ( IAbi abi)
void setClassName (String testClassName)

(可选)设置要运行的测试类名称。

void setCollectTestsOnly (boolean shouldCollectTest)

启用或禁用测试收集模式

void setCollectsTestsShellTimeout (int timeout)

此方法已弃用。此方法是空操作

void setConfiguration ( IConfiguration config)

注入正在使用的IConfiguration

void setCoverageTarget (String coverageTarget)

设置本次测试的覆盖目标。

void setDebug (boolean debug)

设置检测调试设置。

void setDevice ( ITestDevice device)

注入被测设备。

void setEnforceFormat (boolean enforce)

如果我们强制执行检测的 AJUR 输出格式,则设置为 True。

void setForceAbi (String abi)

设置 force-abi 选项。

void setInstallFile (File installFile)

设置要安装的包含测试的可选文件。

void setIsolatedStorage (boolean isolatedStorage)

设置是否使用隔离存储。

void setMethodName (String testMethodName)

或者,将测试方法设置为运行。

void setMetricCollectors ( collectors) setMetricCollectors ( collectors)

设置为测试运行定义的IMetricCollector的列表。

void setPackageName (String packageName)

设置要运行的 Android 清单包。

void setReRunUsingTestFile (boolean reRunUsingTestFile)

设置 --rerun-from-file 选项。

void setRerunMode (boolean rerun)

或者,设置重新运行模式。

void setRunName (String runName)

设置将提供给侦听器的自定义测试运行名称

void setRunnerName (String runnerName)

(可选)设置要使用的 Android 检测运行器。

void setShellTimeout (long timeout)

或者,设置期望从设备输出 shell 的最长时间(以毫秒为单位)。

void setTestFilePathOnDevice (String testFilePathOnDevice)

或者,将路径设置为位于设备上的文件,该文件应包含要运行的以行分隔的测试类和方法列表(格式:com.foo.Class#method)。

void setTestPackageName (String testPackageName)

设置测试包过滤器。

void setTestSize (String size)

或者,设置要运行的测试大小。

void setTestTimeout (long timeout)

或者,为每个单独的测试运行设置最长时间(以毫秒为单位)。

void setTestsToRun ( tests) setTestsToRun ( tests)

设置应由此 InstrumentationTest 执行的测试集合。

void setWindowAnimation (boolean windowAnimation)

受保护的方法

static excludeNonExecuted ( TestRunResult results)

为了跟踪需要重新运行的内容,过滤掉“NOT_EXECUTED”。

String getClassName ()

获取要运行的类名。

ListInstrumentationParser getListInstrumentationParser ()

获取用于解析“pm list instrumentation”查询的ListInstrumentationParser

String getMethodName ()

获取要运行的测试方法。

String getTestPackageName ()

获取要运行的测试 java 包。

String queryRunnerName ()

查询设备以供测试运行器使用。

void setRunnerArgs (IRemoteAndroidTestRunner runner)

领域

RUN_TESTS_AS_USER_KEY

public static final String RUN_TESTS_AS_USER_KEY

RUN_TESTS_ON_SDK_SANDBOX

public static final String RUN_TESTS_ON_SDK_SANDBOX

调试

protected boolean mDebug

公共构造函数

仪器测试

public InstrumentationTest ()

公共方法

添加设备监听器

public void addDeviceListeners ( extraListeners)

允许向跑步者添加更多自定义侦听器

参数
extraListeners

addInstrumentationArg

public void addInstrumentationArg (String key, 
                String value)

添加一个参数以在运行仪器测试时提供。

参数
key String :参数名称

value String : 参数值

得到阿比

public IAbi getAbi ()

退货
IAbi

获取配置

public IConfiguration getConfiguration ()

获取此测试的IConfiguration

退货
IConfiguration

获取覆盖目标

public String getCoverageTarget ()

获取之前通过setCoverageTarget(String)设置的 coverageTarget。

退货
String

得到调试

public boolean getDebug ()

获取检测调试设置。

退货
boolean布尔调试设置。

获取设备

public ITestDevice getDevice ()

获取待测设备。

退货
ITestDevice ITestDevice

获取ForceAbi

public String getForceAbi ()

退货
String

获取最大超时时间

public long getMaxTimeout ()

返回为检测设置的最大超时。

退货
long

获取包名

public String getPackageName ()

获取要运行的 Android 清单包。

退货
String

获取运行名称

public String getRunName ()

获取将提供给侦听器的自定义测试运行名称

退货
String

获取RunnerName

public String getRunnerName ()

获取要使用的 Android 检测运行器。

退货
String

跑步

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

运行测试,并将结果报告给侦听器。

参数
testInfo TestInformation :包含运行测试的有用信息的TestInformation对象。

listener ITestInvocationListener : 测试结果的ITestInvocationListener

投掷
DeviceNotAvailableException

设置Abi

public void setAbi (IAbi abi)

参数
abi IAbi

设置类名

public void setClassName (String testClassName)

(可选)设置要运行的测试类名称。

参数
testClassName String

setCollectTestsOnly

public void setCollectTestsOnly (boolean shouldCollectTest)

启用或禁用测试收集模式

setCollectsTestsShellTimeout

public void setCollectsTestsShellTimeout (int timeout)

此方法已弃用。
此方法是空操作

以毫秒为单位设置最长时间,以便在收集测试时允许“shell 输出响应的最长时间”。

参数
timeout int

设置配置

public void setConfiguration (IConfiguration config)

注入正在使用的IConfiguration

参数
config IConfiguration

设置覆盖目标

public void setCoverageTarget (String coverageTarget)

设置本次测试的覆盖目标。

目前未使用。此方法仅存在,因此以后可以通过getCoverageTarget()检索 coverageTarget

参数
coverageTarget String

设置调试

public void setDebug (boolean debug)

设置检测调试设置。

参数
debug boolean : 将检测调试设置设置为的布尔值。

设置设备

public void setDevice (ITestDevice device)

注入被测设备。

参数
device ITestDevice :要使用的ITestDevice

设置强制格式

public void setEnforceFormat (boolean enforce)

如果我们强制执行检测的 AJUR 输出格式,则设置为 True。

参数
enforce boolean

setForceAbi

public void setForceAbi (String abi)

设置 force-abi 选项。

设置安装文件

public void setInstallFile (File installFile)

设置要安装的包含测试的可选文件。

参数
installFile File :可安装的ERROR(/File)

设置隔离存储

public void setIsolatedStorage (boolean isolatedStorage)

设置是否使用隔离存储。

参数
isolatedStorage boolean

设置方法名

public void setMethodName (String testMethodName)

或者,将测试方法设置为运行。

参数
testMethodName String

setMetricCollectors

public void setMetricCollectors ( collectors)

设置为测试运行定义的IMetricCollector的列表。

参数
collectors

设置包名

public void setPackageName (String packageName)

设置要运行的 Android 清单包。

参数
packageName String

setReRunUsingTestFile

public void setReRunUsingTestFile (boolean reRunUsingTestFile)

设置 --rerun-from-file 选项。

参数
reRunUsingTestFile boolean

设置重新运行模式

public void setRerunMode (boolean rerun)

或者,设置重新运行模式。

参数
rerun boolean

设置运行名称

public void setRunName (String runName)

设置将提供给侦听器的自定义测试运行名称

参数
runName String

设置RunnerName

public void setRunnerName (String runnerName)

(可选)设置要使用的 Android 检测运行器。

参数
runnerName String

设置ShellTimeout

public void setShellTimeout (long timeout)

或者,设置期望从设备输出 shell 的最长时间(以毫秒为单位)。

参数
timeout long

setTestFilePathOnDevice

public void setTestFilePathOnDevice (String testFilePathOnDevice)

或者,将路径设置为位于设备上的文件,该文件应包含要运行的以行分隔的测试类和方法列表(格式:com.foo.Class#method)。如果设置,将自动尝试通过InstrumentationFileTest使用此测试文件重新运行测试,而不是通过重新运行为每个剩余测试执行单独的 adb 命令。

参数
testFilePathOnDevice String

设置测试包名称

public void setTestPackageName (String testPackageName)

设置测试包过滤器。

如果非空,将只执行给定 java 包中的测试。

如果已向setClassName(String)提供非空值,将被忽略

参数
testPackageName String

设置测试大小

public void setTestSize (String size)

或者,设置要运行的测试大小。

参数
size String

设置测试超时

public void setTestTimeout (long timeout)

或者,为每个单独的测试运行设置最长时间(以毫秒为单位)。

参数
timeout long

设置测试运行

public void setTestsToRun ( tests)

设置应由此 InstrumentationTest 执行的测试集合。

参数
tests :要运行的测试

设置窗口动画

public void setWindowAnimation (boolean windowAnimation)

参数
windowAnimation boolean

受保护的方法

排除未执行

protected static  excludeNonExecuted (TestRunResult results)

为了跟踪需要重新运行的内容,过滤掉“NOT_EXECUTED”。

参数
results TestRunResult

退货

获取类名

protected String getClassName ()

获取要运行的类名。

退货
String

getListInstrumentationParser

protected ListInstrumentationParser getListInstrumentationParser ()

获取用于解析“pm list instrumentation”查询的ListInstrumentationParser

退货
ListInstrumentationParser

获取方法名

protected String getMethodName ()

获取要运行的测试方法。

退货
String

获取测试包名称

protected String getTestPackageName ()

获取要运行的测试 java 包。

退货
String

queryRunnerName

protected String queryRunnerName ()

查询设备以供测试运行器使用。

退货
String第一个与包匹配的测试运行器名称,如果找不到则为 null。

投掷
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

setRunnerArgs

protected void setRunnerArgs (IRemoteAndroidTestRunner runner)

参数
runner IRemoteAndroidTestRunner