UiAutomatorRunner

public class UiAutomatorRunner
extends Object implements IRemoteAndroidTestRunner

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


在设备上运行 UI Automator 测试并报告结果。 UI Automator 测试是一个专用的测试运行器,用于运行利用 UI Automator 框架的 UI 自动化测试。设备上的测试运行程序模拟仪器测试输出格式,以便可以重用 ddmlib 和 TF 中的现有解析代码。本质上,这是此命令的包装器: adb shell uiautomator runtest (jar files) -e class (测试类) ...

概括

公共构造函数

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

创建 UiAutomatorRunner 来运行 UI 自动化测试

公共方法

void addBooleanArg (String name, boolean value)

void addInstrumentationArg (String name, String value)

void cancel ()

IRemoteAndroidTestRunner.CoverageOutput getCoverageOutputType ()
String getPackageName ()

返回最后添加的 Java 类的包名称

String getRunnerName ()

返回默认的 UiAutomatorTestRunner 类名

void removeInstrumentationArg (String name)

void run (ITestRunListener... listeners)

void run ( listeners) 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)

设置 uiautomator 中的选项以忽略 SIGHUP。

void setLogOnly (boolean logOnly)

void setMaxTimeToOutputResponse (long timeout, TimeUnit unit)

void setMaxTimeout (long maxTimeout, TimeUnit unit)
void setMaxtimeToOutputResponse (int maxTimeToOutputResponse)

此方法已被弃用。使用setMaxTimeToOutputResponse(long, TimeUnit)代替。

void setMethodName (String className, String testName)

void setRunName (String runName)

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

void setTestSize (IRemoteAndroidTestRunner.TestSize size)

受保护的方法

String getRunCommand ()
String getRunnerPath ()

公共构造函数

UiAutomatorRunner

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

创建 UiAutomatorRunner 来运行 UI 自动化测试

参数
remoteDevice IDevice :与之交互的远程设备:运行测试、收集结果等

jarPaths String :UI Automator 测试用例所在的 jar 文件的路径;路径必须是绝对路径或相对于设备上的 /data/local/tmp/

runnerPath String :要使用的替代 uiautomator 运行程序,可能为null ,在这种情况下将使用默认值

公共方法

添加布尔参数

public void addBooleanArg (String name, 
                boolean value)

参数
name String

value boolean

添加InstrumentationArg

public void addInstrumentationArg (String name, 
                String value)

参数
name String

value String

取消

public void cancel ()

获取覆盖输出类型

public IRemoteAndroidTestRunner.CoverageOutput getCoverageOutputType ()

退货
IRemoteAndroidTestRunner.CoverageOutput

获取包名

public String getPackageName ()

返回最后添加的 Java 类的包名称

退货
String

获取跑步者姓名

public String getRunnerName ()

返回默认的 UiAutomatorTestRunner 类名

退货
String

删除InstrumentationArg

public void removeInstrumentationArg (String name)

参数
name String

跑步

public void run (ITestRunListener... listeners)

参数
listeners ITestRunListener

投掷
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

跑步

public void run ( listeners)

参数
listeners

投掷
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

设置附加测试输出位置

public void setAdditionalTestOutputLocation (String additionalTestDataPath)

参数
additionalTestDataPath String

设置类名

public void setClassName (String className)

参数
className String

设置类名

public void setClassNames (String[] classNames)

参数
classNames String

设置覆盖范围

public void setCoverage (boolean coverage)

参数
coverage boolean

设置覆盖率报告位置

public void setCoverageReportLocation (String arg0)

参数
arg0 String

设置调试

public void setDebug (boolean debug)

参数
debug boolean

设置忽略警告

public void setIgnoreSighup (boolean value)

设置 uiautomator 中的选项以忽略 SIGHUP。

参数
value boolean :如果设置为 true 则忽略信号

设置仅记录

public void setLogOnly (boolean logOnly)

参数
logOnly boolean

设置输出响应最大时间

public void setMaxTimeToOutputResponse (long timeout, 
                TimeUnit unit)

参数
timeout long

unit TimeUnit

设置最大超时时间

public void setMaxTimeout (long maxTimeout, 
                TimeUnit unit)

参数
maxTimeout long

unit TimeUnit

设置输出响应最大时间

public void setMaxtimeToOutputResponse (int maxTimeToOutputResponse)

此方法已被弃用。
使用setMaxTimeToOutputResponse(long, TimeUnit)代替。

参数
maxTimeToOutputResponse int

设置方法名

public void setMethodName (String className, 
                String testName)

参数
className String

testName String

设置运行名称

public void setRunName (String runName)

参数
runName String

设置测试集合

public void setTestCollection (boolean b)

参数
b boolean

设置测试包名称

public void setTestPackageName (String packageName)

参数
packageName String

设置测试大小

public void setTestSize (IRemoteAndroidTestRunner.TestSize size)

参数
size IRemoteAndroidTestRunner.TestSize

受保护的方法

获取运行命令

protected String getRunCommand ()

退货
String

获取跑步者路径

protected String getRunnerPath ()

退货
String