DeviceTestRunOptions

public class DeviceTestRunOptions
extends Object

java.lang.Object
   ↳ com.android.tradefed.testtype.junit4.DeviceTestRunOptions


A builder class for options related to running device tests through BaseHostJUnit4Test.

Summary

Public constructors

DeviceTestRunOptions(String packageName)

Public methods

DeviceTestRunOptions addExtraListener(ITestLifeCycleReceiver listener)

Add an extra listener to the instrumentation being run.

DeviceTestRunOptions addInstrumentationArg(String key, String value)

Add an argument that will be passed to the instrumentation.

void clearExtraListeners()
void clearInstrumentationArgs()

Clear all instrumentation arguments that have been set with addInstrumentationArg(String, String) previously.

String getApkFileName()

Returns the name of the apk file for the apk installation.

ITestDevice getDevice()
getExtraListeners()
String[] getInstallArgs()

Returns extra options of the install command.

getInstrumentationArgs()
Long getMaxInstrumentationTimeoutMs()
Long getMaxTimeToOutputMs()
String getPackageName()
String getRunner()
String getTestClassName()
String getTestMethodName()
Long getTestTimeoutMs()
Integer getUserId()
boolean isForceQueryable()

Whether or not the apk to be installed should be queryable.

boolean isGrantPermission()

Whether to grant permissions for the apk installation.

boolean isHiddenApiCheckDisabled()
boolean isIsolatedStorageDisabled()
boolean isRestartDisabled()
boolean isTestApiCheckDisabled()
boolean isWindowAnimationDisabled()
DeviceTestRunOptions setApkFileName(String apkFileName)

Sets the name of the apk file for the apk installation.

DeviceTestRunOptions setCheckResults(boolean checkResults)

Sets whether or not the results of the instrumentation run should be checked and ensure no failures occured.

DeviceTestRunOptions setDevice(ITestDevice device)
DeviceTestRunOptions setDisableHiddenApiCheck(boolean disableHiddenApiCheck)

sets whether or not to add the --no-hidden-api-checks to the 'am instrument' used from the host side.

DeviceTestRunOptions setDisableIsolatedStorage(boolean disableIsolatedStorage)

sets whether or not to add the --no-isolated-storage to the 'am instrument' used from the host side.

DeviceTestRunOptions setDisableRestart(boolean disableRestart)

Sets whether or not to add --no-restart to the 'am instrument' used from the host side.

DeviceTestRunOptions setDisableTestApiCheck(boolean disableTestApiCheck)

sets whether or not to add the --no-test-api-access to the 'am instrument' used from the host side.

DeviceTestRunOptions setDisableWindowAnimation(boolean disableWindowAnimation)

sets whether or not to add the --no-window-animation to the 'am instrument' used from the host side.

DeviceTestRunOptions setForceQueryable(boolean forceQueryable)

Sets false if the apk to be installed should not be queryable.

DeviceTestRunOptions setGrantPermission(boolean grantPermission)

Grants permissions for the apk installation.

DeviceTestRunOptions setInstallArgs(String... installArgs)

Sets extra options of the install command.

DeviceTestRunOptions setMaxInstrumentationTimeoutMs(Long maxInstrumentationTimeoutMs)

Sets the maximum time (in milliseconds) the complete instrumentation will have to run and complete.

DeviceTestRunOptions setMaxTimeToOutputMs(Long maxTimeToOutputMs)

Sets the maximum time (in milliseconds) the instrumentation can stop outputting before being stopped.

DeviceTestRunOptions setRunner(String runner)

Sets the instrumentation runner that should be used to run the instrumentation.

DeviceTestRunOptions setTestClassName(String testClassName)

Sets the classname that the instrumentation should run.

DeviceTestRunOptions setTestMethodName(String testMethodName)

Sets the method name that the instrumentation should run.

DeviceTestRunOptions setTestTimeoutMs(Long testTimeoutMs)

Sets the maximum time (in milliseconds) a test can run before being interrupted.

DeviceTestRunOptions setUserId(Integer userId)

Sets the user id against which the instrumentation should run.

boolean shouldCheckResults()

Public constructors

DeviceTestRunOptions

public DeviceTestRunOptions (String packageName)

Parameters
packageName String

Public methods

addExtraListener

public DeviceTestRunOptions addExtraListener (ITestLifeCycleReceiver listener)

Add an extra listener to the instrumentation being run.

Parameters
listener ITestLifeCycleReceiver

Returns
DeviceTestRunOptions

addInstrumentationArg

public DeviceTestRunOptions addInstrumentationArg (String key, 
                String value)

Add an argument that will be passed to the instrumentation.

Parameters
key String

value String

Returns
DeviceTestRunOptions

clearExtraListeners

public void clearExtraListeners ()

clearInstrumentationArgs

public void clearInstrumentationArgs ()

Clear all instrumentation arguments that have been set with addInstrumentationArg(String, String) previously.

getApkFileName

public String getApkFileName ()

Returns the name of the apk file for the apk installation.

Returns
String

getDevice

public ITestDevice getDevice ()

Returns
ITestDevice

getExtraListeners

public  getExtraListeners ()

Returns

getInstallArgs

public String[] getInstallArgs ()

Returns extra options of the install command.

Returns
String[]

getInstrumentationArgs

public  getInstrumentationArgs ()

Returns

getMaxInstrumentationTimeoutMs

public Long getMaxInstrumentationTimeoutMs ()

Returns
Long

getMaxTimeToOutputMs

public Long getMaxTimeToOutputMs ()

Returns
Long

getPackageName

public String getPackageName ()

Returns
String

getRunner

public String getRunner ()

Returns
String

getTestClassName

public String getTestClassName ()

Returns
String

getTestMethodName

public String getTestMethodName ()

Returns
String

getTestTimeoutMs

public Long getTestTimeoutMs ()

Returns
Long

getUserId

public Integer getUserId ()

Returns
Integer

isForceQueryable

public boolean isForceQueryable ()

Whether or not the apk to be installed should be queryable. The default value is true.

Returns
boolean

isGrantPermission

public boolean isGrantPermission ()

Whether to grant permissions for the apk installation.

Returns
boolean

isHiddenApiCheckDisabled

public boolean isHiddenApiCheckDisabled ()

Returns
boolean

isIsolatedStorageDisabled

public boolean isIsolatedStorageDisabled ()

Returns
boolean

isRestartDisabled

public boolean isRestartDisabled ()

Returns
boolean

isTestApiCheckDisabled

public boolean isTestApiCheckDisabled ()

Returns
boolean

isWindowAnimationDisabled

public boolean isWindowAnimationDisabled ()

Returns
boolean

setApkFileName

public DeviceTestRunOptions setApkFileName (String apkFileName)

Sets the name of the apk file for the apk installation.

Parameters
apkFileName String

Returns
DeviceTestRunOptions

setCheckResults

public DeviceTestRunOptions setCheckResults (boolean checkResults)

Sets whether or not the results of the instrumentation run should be checked and ensure no failures occured.

Parameters
checkResults boolean

Returns
DeviceTestRunOptions

setDevice

public DeviceTestRunOptions setDevice (ITestDevice device)

Parameters
device ITestDevice

Returns
DeviceTestRunOptions

setDisableHiddenApiCheck

public DeviceTestRunOptions setDisableHiddenApiCheck (boolean disableHiddenApiCheck)

sets whether or not to add the --no-hidden-api-checks to the 'am instrument' used from the host side.

Parameters
disableHiddenApiCheck boolean

Returns
DeviceTestRunOptions

setDisableIsolatedStorage

public DeviceTestRunOptions setDisableIsolatedStorage (boolean disableIsolatedStorage)

sets whether or not to add the --no-isolated-storage to the 'am instrument' used from the host side.

Parameters
disableIsolatedStorage boolean

Returns
DeviceTestRunOptions

setDisableRestart

public DeviceTestRunOptions setDisableRestart (boolean disableRestart)

Sets whether or not to add --no-restart to the 'am instrument' used from the host side.

Parameters
disableRestart boolean

Returns
DeviceTestRunOptions

setDisableTestApiCheck

public DeviceTestRunOptions setDisableTestApiCheck (boolean disableTestApiCheck)

sets whether or not to add the --no-test-api-access to the 'am instrument' used from the host side.

Parameters
disableTestApiCheck boolean

Returns
DeviceTestRunOptions

setDisableWindowAnimation

public DeviceTestRunOptions setDisableWindowAnimation (boolean disableWindowAnimation)

sets whether or not to add the --no-window-animation to the 'am instrument' used from the host side.

Parameters
disableWindowAnimation boolean

Returns
DeviceTestRunOptions

setForceQueryable

public DeviceTestRunOptions setForceQueryable (boolean forceQueryable)

Sets false if the apk to be installed should not be queryable.

Parameters
forceQueryable boolean

Returns
DeviceTestRunOptions

setGrantPermission

public DeviceTestRunOptions setGrantPermission (boolean grantPermission)

Grants permissions for the apk installation.

Parameters
grantPermission boolean

Returns
DeviceTestRunOptions

setInstallArgs

public DeviceTestRunOptions setInstallArgs (String... installArgs)

Sets extra options of the install command.

Parameters
installArgs String

Returns
DeviceTestRunOptions

setMaxInstrumentationTimeoutMs

public DeviceTestRunOptions setMaxInstrumentationTimeoutMs (Long maxInstrumentationTimeoutMs)

Sets the maximum time (in milliseconds) the complete instrumentation will have to run and complete. Set to 0 for no timeout. Optional.

Parameters
maxInstrumentationTimeoutMs Long

Returns
DeviceTestRunOptions

setMaxTimeToOutputMs

public DeviceTestRunOptions setMaxTimeToOutputMs (Long maxTimeToOutputMs)

Sets the maximum time (in milliseconds) the instrumentation can stop outputting before being stopped. Set to 0 for no timeout. Optional.

Parameters
maxTimeToOutputMs Long

Returns
DeviceTestRunOptions

setRunner

public DeviceTestRunOptions setRunner (String runner)

Sets the instrumentation runner that should be used to run the instrumentation. Default runner is 'android.support.test.runner.AndroidJUnitRunner'. Optional.

Parameters
runner String

Returns
DeviceTestRunOptions

setTestClassName

public DeviceTestRunOptions setTestClassName (String testClassName)

Sets the classname that the instrumentation should run. The instrumentation will be filtered to only run the class. Can be used with setTestMethodName(String). Optional.

Parameters
testClassName String

Returns
DeviceTestRunOptions

setTestMethodName

public DeviceTestRunOptions setTestMethodName (String testMethodName)

Sets the method name that the instrumentation should run. Requires setTestClassName(String) to be set in order to work properly. Optional.

Parameters
testMethodName String

Returns
DeviceTestRunOptions

setTestTimeoutMs

public DeviceTestRunOptions setTestTimeoutMs (Long testTimeoutMs)

Sets the maximum time (in milliseconds) a test can run before being interrupted. Set to 0 for no timeout. Optional.

Parameters
testTimeoutMs Long

Returns
DeviceTestRunOptions

setUserId

public DeviceTestRunOptions setUserId (Integer userId)

Sets the user id against which the instrumentation should run. Optional.

Parameters
userId Integer

Returns
DeviceTestRunOptions

shouldCheckResults

public boolean shouldCheckResults ()

Returns
boolean