设备测试运行选项
public class DeviceTestRunOptions
extends Object
java.lang.Object | |
↳ | com.android.tradefed.testtype.junit4.DeviceTestRunOptions |
与通过 BaseHostJUnit4Test 运行设备测试相关的选项的构建器类。
概括
公共构造函数 | |
---|---|
DeviceTestRunOptions (String packageName) |
公共方法 | |
---|---|
DeviceTestRunOptions | addExtraListener ( ITestLifeCycleReceiver listener) 向正在运行的检测添加一个额外的侦听器。 |
DeviceTestRunOptions | addInstrumentationArg (String key, String value) 添加将传递给检测的参数。 |
void | clearExtraListeners () |
void | clearInstrumentationArgs () 清除之前使用 |
String | getApkFileName () 返回 apk 安装的 apk 文件的名称。 |
ITestDevice | getDevice () |
getExtraListeners () | |
String[] | getInstallArgs () 返回安装命令的额外选项。 |
getInstrumentationArgs () | |
Long | getMaxInstrumentationTimeoutMs () |
Long | getMaxTimeToOutputMs () |
String | getPackageName () |
String | getRunner () |
String | getTestClassName () |
String | getTestMethodName () |
Long | getTestTimeoutMs () |
Integer | getUserId () |
boolean | isForceQueryable () 要安装的 apk 是否应该是可查询的。 |
boolean | isGrantPermission () 是否授予apk安装权限。 |
boolean | isHiddenApiCheckDisabled () |
boolean | isIsolatedStorageDisabled () |
boolean | isRestartDisabled () |
boolean | isTestApiCheckDisabled () |
boolean | isWindowAnimationDisabled () |
DeviceTestRunOptions | setApkFileName (String apkFileName) 为 apk 安装设置 apk 文件的名称。 |
DeviceTestRunOptions | setCheckResults (boolean checkResults) 设置是否应检查检测运行的结果并确保没有发生故障。 |
DeviceTestRunOptions | setDevice ( ITestDevice device) |
DeviceTestRunOptions | setDisableHiddenApiCheck (boolean disableHiddenApiCheck) 设置是否将 --no-hidden-api-checks 添加到主机端使用的“am instrument”。 |
DeviceTestRunOptions | setDisableIsolatedStorage (boolean disableIsolatedStorage) 设置是否将 --no-isolated-storage 添加到主机端使用的“am instrument”。 |
DeviceTestRunOptions | setDisableRestart (boolean disableRestart) 设置是否将 --no-restart 添加到主机端使用的“am instrument”。 |
DeviceTestRunOptions | setDisableTestApiCheck (boolean disableTestApiCheck) 设置是否将 --no-test-api-access 添加到主机端使用的“am instrument”。 |
DeviceTestRunOptions | setDisableWindowAnimation (boolean disableWindowAnimation) 设置是否将 --no-window-animation 添加到主机端使用的“am instrument”。 |
DeviceTestRunOptions | setForceQueryable (boolean forceQueryable) 如果要安装的 apk 不可查询,则设置 |
DeviceTestRunOptions | setGrantPermission (boolean grantPermission) 授予 apk 安装权限。 |
DeviceTestRunOptions | setInstallArgs (String... installArgs) 设置安装命令的额外选项。 |
DeviceTestRunOptions | setMaxInstrumentationTimeoutMs (Long maxInstrumentationTimeoutMs) 设置完整检测必须运行和完成的最长时间(以毫秒为单位)。 |
DeviceTestRunOptions | setMaxTimeToOutputMs (Long maxTimeToOutputMs) 设置仪器在停止之前可以停止输出的最长时间(以毫秒为单位)。 |
DeviceTestRunOptions | setRunner (String runner) 设置应该用于运行检测的检测运行器。 |
DeviceTestRunOptions | setTestClassName (String testClassName) 设置检测应该运行的类名。 |
DeviceTestRunOptions | setTestMethodName (String testMethodName) 设置检测应运行的方法名称。 |
DeviceTestRunOptions | setTestTimeoutMs (Long testTimeoutMs) 设置测试在被中断之前可以运行的最长时间(以毫秒为单位)。 |
DeviceTestRunOptions | setUserId (Integer userId) 设置检测应针对其运行的用户 ID。 |
boolean | shouldCheckResults () |
公共构造函数
设备测试运行选项
public DeviceTestRunOptions (String packageName)
参数 | |
---|---|
packageName | String |
公共方法
添加额外监听器
public DeviceTestRunOptions addExtraListener (ITestLifeCycleReceiver listener)
向正在运行的检测添加一个额外的侦听器。
参数 | |
---|---|
listener | ITestLifeCycleReceiver |
退货 | |
---|---|
DeviceTestRunOptions |
addInstrumentationArg
public DeviceTestRunOptions addInstrumentationArg (String key, String value)
添加将传递给检测的参数。
参数 | |
---|---|
key | String |
value | String |
退货 | |
---|---|
DeviceTestRunOptions |
clearExtraListeners
public void clearExtraListeners ()
clearInstrumentationArgs
public void clearInstrumentationArgs ()
清除之前使用addInstrumentationArg(String, String)
设置的所有检测参数。
获取Apk文件名
public String getApkFileName ()
返回 apk 安装的 apk 文件的名称。
退货 | |
---|---|
String |
getExtraListeners
publicgetExtraListeners ()
退货 | |
---|---|
获取安装参数
public String[] getInstallArgs ()
返回安装命令的额外选项。
退货 | |
---|---|
String[] |
getInstrumentationArgs
publicgetInstrumentationArgs ()
退货 | |
---|---|
getMaxInstrumentationTimeoutMs
public Long getMaxInstrumentationTimeoutMs ()
退货 | |
---|---|
Long |
getMaxTimeToOutputMs
public Long getMaxTimeToOutputMs ()
退货 | |
---|---|
Long |
获取包名
public String getPackageName ()
退货 | |
---|---|
String |
获取亚军
public String getRunner ()
退货 | |
---|---|
String |
获取测试类名称
public String getTestClassName ()
退货 | |
---|---|
String |
获取测试方法名称
public String getTestMethodName ()
退货 | |
---|---|
String |
getTestTimeoutMs
public Long getTestTimeoutMs ()
退货 | |
---|---|
Long |
获取用户ID
public Integer getUserId ()
退货 | |
---|---|
Integer |
isForceQueryable
public boolean isForceQueryable ()
要安装的 apk 是否应该是可查询的。默认值是true。
退货 | |
---|---|
boolean |
isGrantPermission
public boolean isGrantPermission ()
是否授予apk安装权限。
退货 | |
---|---|
boolean |
isHiddenApiCheckDisabled
public boolean isHiddenApiCheckDisabled ()
退货 | |
---|---|
boolean |
isIsolatedStorageDisabled
public boolean isIsolatedStorageDisabled ()
退货 | |
---|---|
boolean |
isRestartDisabled
public boolean isRestartDisabled ()
退货 | |
---|---|
boolean |
isTestApiCheckDisabled
public boolean isTestApiCheckDisabled ()
退货 | |
---|---|
boolean |
isWindowAnimationDisabled
public boolean isWindowAnimationDisabled ()
退货 | |
---|---|
boolean |
设置Apk文件名
public DeviceTestRunOptions setApkFileName (String apkFileName)
为 apk 安装设置 apk 文件的名称。
参数 | |
---|---|
apkFileName | String |
退货 | |
---|---|
DeviceTestRunOptions |
设置检查结果
public DeviceTestRunOptions setCheckResults (boolean checkResults)
设置是否应检查检测运行的结果并确保没有发生故障。
参数 | |
---|---|
checkResults | boolean |
退货 | |
---|---|
DeviceTestRunOptions |
设置设备
public DeviceTestRunOptions setDevice (ITestDevice device)
参数 | |
---|---|
device | ITestDevice |
退货 | |
---|---|
DeviceTestRunOptions |
setDisableHiddenApiCheck
public DeviceTestRunOptions setDisableHiddenApiCheck (boolean disableHiddenApiCheck)
设置是否将 --no-hidden-api-checks 添加到主机端使用的“am instrument”。
参数 | |
---|---|
disableHiddenApiCheck | boolean |
退货 | |
---|---|
DeviceTestRunOptions |
设置禁用隔离存储
public DeviceTestRunOptions setDisableIsolatedStorage (boolean disableIsolatedStorage)
设置是否将 --no-isolated-storage 添加到主机端使用的“am instrument”。
参数 | |
---|---|
disableIsolatedStorage | boolean |
退货 | |
---|---|
DeviceTestRunOptions |
设置禁用重启
public DeviceTestRunOptions setDisableRestart (boolean disableRestart)
设置是否将 --no-restart 添加到主机端使用的“am instrument”。
参数 | |
---|---|
disableRestart | boolean |
退货 | |
---|---|
DeviceTestRunOptions |
setDisableTestApiCheck
public DeviceTestRunOptions setDisableTestApiCheck (boolean disableTestApiCheck)
设置是否将 --no-test-api-access 添加到主机端使用的“am instrument”。
参数 | |
---|---|
disableTestApiCheck | boolean |
退货 | |
---|---|
DeviceTestRunOptions |
设置禁用窗口动画
public DeviceTestRunOptions setDisableWindowAnimation (boolean disableWindowAnimation)
设置是否将 --no-window-animation 添加到主机端使用的“am instrument”。
参数 | |
---|---|
disableWindowAnimation | boolean |
退货 | |
---|---|
DeviceTestRunOptions |
setForceQueryable
public DeviceTestRunOptions setForceQueryable (boolean forceQueryable)
如果要安装的 apk 不可查询,则设置false
。
参数 | |
---|---|
forceQueryable | boolean |
退货 | |
---|---|
DeviceTestRunOptions |
设置授权
public DeviceTestRunOptions setGrantPermission (boolean grantPermission)
授予 apk 安装权限。
参数 | |
---|---|
grantPermission | boolean |
退货 | |
---|---|
DeviceTestRunOptions |
设置安装参数
public DeviceTestRunOptions setInstallArgs (String... installArgs)
设置安装命令的额外选项。
参数 | |
---|---|
installArgs | String |
退货 | |
---|---|
DeviceTestRunOptions |
setMaxInstrumentationTimeoutMs
public DeviceTestRunOptions setMaxInstrumentationTimeoutMs (Long maxInstrumentationTimeoutMs)
设置完整检测必须运行和完成的最长时间(以毫秒为单位)。设置为 0 表示没有超时。选修的。
参数 | |
---|---|
maxInstrumentationTimeoutMs | Long |
退货 | |
---|---|
DeviceTestRunOptions |
setMaxTimeToOutputMs
public DeviceTestRunOptions setMaxTimeToOutputMs (Long maxTimeToOutputMs)
设置仪器在停止之前可以停止输出的最长时间(以毫秒为单位)。设置为 0 表示没有超时。选修的。
参数 | |
---|---|
maxTimeToOutputMs | Long |
退货 | |
---|---|
DeviceTestRunOptions |
设置运行器
public DeviceTestRunOptions setRunner (String runner)
设置应该用于运行检测的检测运行器。默认运行器是“android.support.test.runner.AndroidJUnitRunner”。选修的。
参数 | |
---|---|
runner | String |
退货 | |
---|---|
DeviceTestRunOptions |
设置测试类名称
public DeviceTestRunOptions setTestClassName (String testClassName)
设置检测应该运行的类名。仪器将被过滤以仅运行该类。可以与setTestMethodName(String)
一起使用。选修的。
参数 | |
---|---|
testClassName | String |
退货 | |
---|---|
DeviceTestRunOptions |
设置测试方法名称
public DeviceTestRunOptions setTestMethodName (String testMethodName)
设置检测应运行的方法名称。需要设置setTestClassName(String)
才能正常工作。选修的。
参数 | |
---|---|
testMethodName | String |
退货 | |
---|---|
DeviceTestRunOptions |
setTestTimeoutMs
public DeviceTestRunOptions setTestTimeoutMs (Long testTimeoutMs)
设置测试在被中断之前可以运行的最长时间(以毫秒为单位)。设置为 0 表示没有超时。选修的。
参数 | |
---|---|
testTimeoutMs | Long |
退货 | |
---|---|
DeviceTestRunOptions |
设置用户Id
public DeviceTestRunOptions setUserId (Integer userId)
设置检测应针对其运行的用户 ID。选修的。
参数 | |
---|---|
userId | Integer |
退货 | |
---|---|
DeviceTestRunOptions |
应该检查结果
public boolean shouldCheckResults ()
退货 | |
---|---|
boolean |