Uiautomator向jar包传多个参数
来源:互联网 发布:网络奇兵武器 编辑:程序博客网 时间:2024/06/09 18:33
先看uiautomator的命令解析,随便输了个uiautomator -help,让其显示用法,打印出来的信息如下:
——————————————————————————————————————————————————————————————
shell@V4:/ $ uiautomator -help
uiautomator -helpUsage: uiautomator <subcommand> [options]
Available subcommands:
help: displays help message
runtest: executes UI automation tests
runtest <class spec> [options]
<class spec>: <JARS> < -c <CLASSES> | -e class <CLASSES> >
<JARS>: a list of jar files containing test classes and dependencies. If
the path is relative, it's assumed to be under /data/local/tmp. Use
absolute path if the file is elsewhere. Multiple files can be
specified, separated by space.
<CLASSES>: a list of test class names to run, separated by comma. To
a single method, use TestClass#testMethod format. The -e or -c option
may be repeated. This option is not required and if not provided then
all the tests in provided jars will be run automatically.
options:
--nohup: trap SIG_HUP, so test won't terminate even if parent process
is terminated, e.g. USB is disconnected.
-e debug [true|false]: wait for debugger to connect before starting.
-e runner [CLASS]: use specified test runner class instead. If
unspecified, framework default runner will be used.
-e <NAME> <VALUE>: other name-value pairs to be passed to test classes.
May be repeated.
-e outputFormat simple | -s: enabled less verbose JUnit style output.
dump: creates an XML dump of current UI hierarchy
dump [--verbose][file]
[--compressed]: dumps compressed layout information.
[file]: the location where the dumped XML should be stored, default is
/storage/emulated/legacy/window_dump.xml
events: prints out accessibility events until terminated
————————————————————————————————————————————————————————————————————
上面红色文字部分,即使解释如何传参,下面用一个例子说明其用法:
假设我需要想jar包穿三个参数,String uiserName,String password,long runTime,则对应的命令应该如下:
uiautomator runtest TestLogin.jar-e userName CrystalChen -e runTime 1000000 -e password 123 --nohup -c com.example.TestLogin
下划线斜体部分则为对应的参数配置。
在你的UiautomatorTestCase中对应接受参数的地方应该书写如下:
public void test1() throws Exception {Bundle bundle=getParams();//获取键值对String userName=bundle.getString("userName");String password=bundle.getString("password");long runTime=Long.parseLong(bundle.getString("runTime"));System.out.println(runTime+"======="+password+"========"+userName);}
注意:非String类型的参数不能通过bundle.getLong这种方法获取,这样是获取不到的,这些键值对必须通过getString来获取,然后对应转化成你要的类型。
0 0
- Uiautomator向jar包传多个参数
- Uiautomator向jar包传多个参数
- uiautomator runtest命令行向jar文件传参
- uiautomator传入参数长度
- Uiautomator 2 调试参数传递
- UiAutomator运行命令时传多个参数
- UIAutomator如何添加第三方jar包
- android uiautomator使用第三方jar
- Uiautomator依赖jar包找不到的提示
- uiautomator
- uiautomator
- uiautomator
- UIAutomator
- Uiautomator
- Android-Uiautomator:[6]运行中传入参数
- uiautomator如何添加随机参数--正则表达式
- 向setTimeout传递函数参数
- 向sqlplus传递参数
- iOS中CATransition 用法(各种风格的跳转页面特效)
- Jlink克隆版和谐处理
- 每日一问之activity的进出动画
- Oracle 补丁下载及安装简介CPU/PSU
- 无损音乐下载器 Delphi版
- Uiautomator向jar包传多个参数
- 怎么在Caffe中配置每一个层的结构
- Activity Task
- bootstrap-switch(开关插件)
- 记录-mysql的sql执行效率方法
- Java设计模式 状态模式(State)
- 遍历结果集,执行20条insert语句
- Python 换行符转换
- 文本分类与SVM