测试中有些可变参数如何,根据不同的情况,传入到脚本中呢
uiautomator是有提供传入的办法的
方法/步骤
-
-e 后面跟着一对bundle键值对
如:我要传入一个电话号码,让脚本拨打指定的号码
publicclassDialSuiteextendsLenovoUiTestCase{
privateStringphoneNumber="10086";//默认拨打10086
publicvoidtestDemo(){
Bundlephone=getParams();//获取键值对
if(phone.getString("phone")!=null){
phoneNumber=phone.getString(“phone”);//安装键值提取电话号码
}
dial(phoneNumber);//拨打指定电话号码
}}
-
编译完后,我们可以用如下命令进行运行,传入参数,让手机拨打18888888888
adb shell uiautomator runtest test.jar –e phone 18888888888 -c com.demo.DialSuite
-
转自:http://jingyan.baidu.com/article/ca2d939d2a88b2eb6c31cef3.html