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()

IRemoteAndroidTestRunner.CoverageOutput getCoverageOutputType()
String getPackageName()

Returns the package name of last Java class added

String getRunnerName()

Returns default UiAutomatorTestRunner class name

void removeInstrumentationArg(String name)

void run(ITestRunListener... listeners)

void run( listeners)

void setAdditionalTestOutputLocation(String additionalTestDataPath)
void setClassName(String className)

void setClassNames(String[] classNames)

void setCoverage(boolean coverage)

void setCoverageReportLocation(String arg0)
void setDebug(boolean debug)

void setIgnoreSighup(boolean value)

Sets the option in the uiautomator to ignore SIGHUP.

void setLogOnly(boolean logOnly)

void setMaxTimeToOutputResponse(long timeout, TimeUnit unit)

void setMaxTimeout(long maxTimeout, 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

public 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

public void addBooleanArg (String name, 
                boolean value)

Parameters
name String

value boolean

addInstrumentationArg

public void addInstrumentationArg (String name, 
                String value)

Parameters
name String

value String

cancel

public void cancel ()

getCoverageOutputType

public IRemoteAndroidTestRunner.CoverageOutput getCoverageOutputType ()

Returns
IRemoteAndroidTestRunner.CoverageOutput

getPackageName

public String getPackageName ()

Returns the package name of last Java class added

Returns
String

getRunnerName

public String getRunnerName ()

Returns default UiAutomatorTestRunner class name

Returns
String

removeInstrumentationArg

public void removeInstrumentationArg (String name)

Parameters
name String

run

public void run (ITestRunListener... listeners)

Parameters
listeners ITestRunListener

Throws
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

run

public void run ( listeners)

Parameters
listeners

Throws
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

setAdditionalTestOutputLocation

public void setAdditionalTestOutputLocation (String additionalTestDataPath)

Parameters
additionalTestDataPath String

setClassName

public void setClassName (String className)

Parameters
className String

setClassNames

public void setClassNames (String[] classNames)

Parameters
classNames String

setCoverage

public void setCoverage (boolean coverage)

Parameters
coverage boolean

setCoverageReportLocation

public void setCoverageReportLocation (String arg0)

Parameters
arg0 String

setDebug

public void setDebug (boolean debug)

Parameters
debug boolean

setIgnoreSighup

public void setIgnoreSighup (boolean value)

Sets the option in the uiautomator to ignore SIGHUP.

Parameters
value boolean: ignore the signal if set to true

setLogOnly

public void setLogOnly (boolean logOnly)

Parameters
logOnly boolean

setMaxTimeToOutputResponse

public void setMaxTimeToOutputResponse (long timeout, 
                TimeUnit unit)

Parameters
timeout long

unit TimeUnit

setMaxTimeout

public void setMaxTimeout (long maxTimeout, 
                TimeUnit unit)

Parameters
maxTimeout long

unit TimeUnit

setMaxtimeToOutputResponse

public void setMaxtimeToOutputResponse (int maxTimeToOutputResponse)

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

Parameters
maxTimeToOutputResponse int

setMethodName

public void setMethodName (String className, 
                String testName)

Parameters
className String

testName String

setRunName

public void setRunName (String runName)

Parameters
runName String

setTestCollection

public void setTestCollection (boolean b)

Parameters
b boolean

setTestPackageName

public void setTestPackageName (String packageName)

Parameters
packageName String

setTestSize

public void setTestSize (IRemoteAndroidTestRunner.TestSize size)

Parameters
size IRemoteAndroidTestRunner.TestSize

Protected methods

getRunCommand

protected String getRunCommand ()

Returns
String

getRunnerPath

protected String getRunnerPath ()

Returns
String