仪表测试
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 () 获取此测试的 |
String | getCoverageTarget () 获取之前通过 |
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) 注入正在使用的 |
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) 设置为测试运行定义的 |
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”查询的 |
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
mDebug
protected boolean mDebug
公共构造函数
仪表测试
public InstrumentationTest ()
公共方法
addDeviceListeners
public void addDeviceListeners (extraListeners)
允许向跑步者添加更多自定义侦听器
参数 | |
---|---|
extraListeners |
addInstrumentationArg
public void addInstrumentationArg (String key, String value)
在运行检测测试时添加要提供的参数。
参数 | |
---|---|
key | String :参数名称 |
value | String : 参数值 |
获取调试
public boolean getDebug ()
获取仪器调试设置。
退货 | |
---|---|
boolean | 布尔调试设置。 |
getForceAbi
public String getForceAbi ()
退货 | |
---|---|
String |
getMaxTimeout
public long getMaxTimeout ()
返回为检测设置的最大超时。
退货 | |
---|---|
long |
获取包裹名称
public String getPackageName ()
获取要运行的 Android 清单包。
退货 | |
---|---|
String |
获取运行名称
public String getRunName ()
获取将提供给侦听器的自定义测试运行名称
退货 | |
---|---|
String |
获取跑步者姓名
public String getRunnerName ()
获取要使用的 Android 检测运行器。
退货 | |
---|---|
String |
跑
public void run (TestInformation testInfo, ITestInvocationListener listener)
运行测试,并将结果报告给监听器。
参数 | |
---|---|
testInfo | TestInformation : TestInformation 对象包含运行测试的有用信息。 |
listener | ITestInvocationListener : 测试结果的ITestInvocationListener |
投掷 | |
---|---|
DeviceNotAvailableException |
设置类名
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 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 |
setRunnerName
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 |
setTestsToRun
public void setTestsToRun (tests)
设置应由此 InstrumentationTest 执行的测试集合。
参数 | |
---|---|
tests |
设置窗口动画
public void setWindowAnimation (boolean windowAnimation)
参数 | |
---|---|
windowAnimation | boolean |
受保护的方法
excludeNonExecuted
protected staticexcludeNonExecuted (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。 |
投掷 | |
---|---|
DeviceNotAvailableException |
setRunnerArgs
protected void setRunnerArgs (IRemoteAndroidTestRunner runner)
参数 | |
---|---|
runner | IRemoteAndroidTestRunner |