UiAutomatorRunner

public class UiAutomatorRunner
extends Object implements IRemoteAndroidTestRunner

java.lang.Object
   ↳ com.android.tradefed.testtype.UiAutomatorRunner


Runs UI Automator test on device and reports results. UI Automator test is a dedicated test runner for running UI automation tests that utilizes UI Automator framework. The test runner on device emulates instrumentation test output format so that existing parsing code in ddmlib and TF can be reused. Essentially, this is a wrapper around this command: adb shell uiautomator runtest (jar files) -e class (test classes) ...

Summary

Public constructors

UiAutomatorRunner(IDevice remoteDevice, String[] jarPaths, String runnerPath)

Create a UiAutomatorRunner for running UI automation tests

Public methods

void addBooleanArg(String name, boolean value)

void addInstrumentationArg(String name, String value)

void cancel()

String getPackageName()

Returns the package name of last Java class added

String getRunnerName()

Returns default UiAutomatorTestRunner class name

void removeInstrumentationArg(String name)

void run(Collection<ITestRunListener> listeners)

void run(ITestRunListener... listeners)

void setClassName(String className)

void setClassNames(String[] classNames)

void setCoverage(boolean coverage)

void setDebug(boolean debug)

void setEnforceTimeStamp(boolean arg0)
void setIgnoreSighup(boolean value)

Sets the option in the uiautomator to ignore SIGHUP.

void setLogOnly(boolean logOnly)

void setMaxTimeToOutputResponse(long timeout, TimeUnit unit)

void setMaxtimeToOutputResponse(int maxTimeToOutputResponse)

This method is deprecated. use setMaxTimeToOutputResponse(long, TimeUnit) instead.

void setMethodName(String className, String testName)

void setRunName(String runName)

void setTestCollection(boolean b)
void setTestPackageName(String packageName)

void setTestSize(IRemoteAndroidTestRunner.TestSize size)

Protected methods

String getRunCommand()
String getRunnerPath()

Public constructors

UiAutomatorRunner

UiAutomatorRunner (IDevice remoteDevice, 
                String[] jarPaths, 
                String runnerPath)

Create a UiAutomatorRunner for running UI automation tests

Parameters
remoteDevice IDevice: the remote device to interact with: run test, collect results etc
jarPaths String: the paths to jar files where UI Automator test cases are; the paths must be absolute or relative to /data/local/tmp/ on device
runnerPath String: alternative uiautomator runner to use, may be null and default will be used in this case

Public methods

addBooleanArg

void addBooleanArg (String name, 
                boolean value)

Parameters
name String
value boolean

addInstrumentationArg

void addInstrumentationArg (String name, 
                String value)

Parameters
name String
value String

cancel

void cancel ()

getPackageName

String getPackageName ()

Returns the package name of last Java class added

Returns
String

getRunnerName

String getRunnerName ()

Returns default UiAutomatorTestRunner class name

Returns
String

removeInstrumentationArg

void removeInstrumentationArg (String name)

Parameters
name String

run

void run (Collection<ITestRunListener> listeners)

Parameters
listeners Collection
Throws
TimeoutException
AdbCommandRejectedException
ShellCommandUnresponsiveException
IOException

run

void run (ITestRunListener... listeners)

Parameters
listeners ITestRunListener
Throws
TimeoutException
AdbCommandRejectedException
ShellCommandUnresponsiveException
IOException

setClassName

void setClassName (String className)

Parameters
className String

setClassNames

void setClassNames (String[] classNames)

Parameters
classNames String

setCoverage

void setCoverage (boolean coverage)

Parameters
coverage boolean

setDebug

void setDebug (boolean debug)

Parameters
debug boolean

setEnforceTimeStamp

void setEnforceTimeStamp (boolean arg0)

Parameters
arg0 boolean

setIgnoreSighup

void setIgnoreSighup (boolean value)

Sets the option in the uiautomator to ignore SIGHUP.

Parameters
value boolean: ignore the signal if set to true

setLogOnly

void setLogOnly (boolean logOnly)

Parameters
logOnly boolean

setMaxTimeToOutputResponse

void setMaxTimeToOutputResponse (long timeout, 
                TimeUnit unit)

Parameters
timeout long
unit TimeUnit

setMaxtimeToOutputResponse

void setMaxtimeToOutputResponse (int maxTimeToOutputResponse)

This method is deprecated.
use setMaxTimeToOutputResponse(long, TimeUnit) instead.

Parameters
maxTimeToOutputResponse int

setMethodName

void setMethodName (String className, 
                String testName)

Parameters
className String
testName String

setRunName

void setRunName (String runName)

Parameters
runName String

setTestCollection

void setTestCollection (boolean b)

Parameters
b boolean

setTestPackageName

void setTestPackageName (String packageName)

Parameters
packageName String

setTestSize

void setTestSize (IRemoteAndroidTestRunner.TestSize size)

Parameters
size IRemoteAndroidTestRunner.TestSize

Protected methods

getRunCommand

String getRunCommand ()

Returns
String

getRunnerPath

String getRunnerPath ()

Returns
String