首页 > 代码库 > 基于Monkey的Android自己主动化測试

基于Monkey的Android自己主动化測试

使用Monkey,能够相应用的稳定性和健壮性进行压測,測试的结果对于产品在复杂环境下的执行情况有很重要的參考意义。

以下是一个演示样例,带有对应的凝视。简单明了。供大家參考。

#!/bin/bash

# define case base information
case_name="monkey case"
case_ver="1.0.2"
case_package_name="cn.packagename.platform"
case_event_scale=5000

echo "-------------------------------------"
echo "Job name:${case_name}, ver:${case_ver}"
echo "-------------------------------------"

# start job
echo "List all connected device and checking them..."
current_date=`date "+%Y-%m-%d %H:%M:%S"`
adb devices > devices.list
if grep -q "	device" devices.list
then
  echo "The package ready for send pseudo random event"
  echo "Case starting..."
  adb shell monkey -p ${case_package_name} -v ${case_event_scale} --pct-motion 50 --pct-syskeys 30 --monitor-native-crashes
  current_date=`date "+%Y-%m-%d %H:%M:%S"`
  current_msg=‘Finished!‘
else
  current_date=`date "+%Y-%m-%d %H:%M:%S"`
  current_msg="WARNNING!!! No devices connected!"

  echo "[${current_date}]${current_msg}" > error.log
fi

# finished
echo "[${current_date}]${current_msg}"
echo "Quiting..."


基于Monkey的Android自己主动化測试