美文网首页
渠道包自动化测试-sh脚本

渠道包自动化测试-sh脚本

作者: 大小姐lemon | 来源:发表于2019-10-14 09:53 被阅读0次

需求描述:

1.所有apk放在一个文件夹内,逐个遍历安装在一部手机上。

2.apk先卸载再安装,运行monkey30min,卸载再安装下一个。

3.输出结果H5:统计各个包,crash次数,对应log,monkeylog。

实现方式:通过在terminal中运行.sh脚本实现。

sh代码:

apkPath_1=/Users/wangyingying/Desktop/apk_qudao/YuPa_1.0.0_20190412193500-huawei-release.apk
apkPath_2=/Users/wangyingying/Desktop/apk_qudao/YuPa_1.0.0_20190412193500-qq-release.apk
apkPath_3=/Users/wangyingying/Desktop/apk_qudao/YuPa_1.0.0_20190412193500-setup-release.apk
apk_lists=(apkPath_1apkPath_2 apkPath_3) packageName=com.meitu.yupa mainActivityName=packageName.module.startup.ui.StartUpActishell

for (( i = 0; i < {#apk_lists[*]}; i++ )); { echo installing...{apk_lists[I]} if (adb install -r{apk_lists[i]} | grep 'Failure') then #判断安装是否失败,可能是签名不一致导致的 echo uninstalling... #输出内容,类似log adb shell pm uninstall{apk_lists[I]} echo reinstalling{apk_lists[I]} adb install -r{apk_lists[$i]} #保留原数据安装
echo success!

else
echo success!
fi
adb shell am start -n packageName/mainActivityName
adb shell monkey -p $packageName 100
echo monkey_1
}

<pre class="plain hljs bash" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; margin: 10px 0px 0px;">运行方法:在.sh文件所在位置,直接执行sh XXX.sh</pre>

shell的一些知识:

1.shell赋值:path=1 中间不能有空格,指向上一个地址

if的语法:

if (true) then

else

fi #end if

2.shell数组相关知识和操作

数组声明:shell是弱语言,可以不用任何声明。

数组定义:数组中的元素,必须以"空格"来隔开

names=(candy cindy abcd windy)

names[0]=candy namesp[1]=cindy ...

names=([0]=candy [1]=cindy ...)

数组长度:

使用{array_name[@]} 或者{array_name[*]} 都可以全部显示数组中的元素

同样道理{#array_name[@]} 或者{#array_name[*]}都可以用来求数组的长度

数组遍历:可以使用标准的for循环

[图片上传中...(image-9879ff-1570881443599-0)]

3..sh文件概念

Windows下批处理文件(.bat),在Mac OS X下(.sh),

使用方法:将命令写在一个文本文件中,保存为.sh文件,将.sh文件直接拖入到终端窗口

<pre style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; margin: 10px 0px 0px;">"appActivity": ".module.startup.ui.StartUpActivity",
"appPackage": "com.meitu.yupa",</pre>

相关文章

网友评论

      本文标题:渠道包自动化测试-sh脚本

      本文链接:https://www.haomeiwen.com/subject/crscmctx.html