• 手机三方应用monkey测试脚本


    package studyjava;
    
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    
    public class monkeytest {
        public static void main(String[] args) throws IOException, Exception
        {
            Process p=Runtime.getRuntime().exec("adb shell pm list packages -3");
            //Thread.sleep(3000);
            InputStream in=p.getInputStream();
            InputStreamReader ir=new InputStreamReader(in);
            BufferedReader br=new BufferedReader(ir);
            String str;
            int testnumber=0;
            while((str=br.readLine())!=null)
            {  
                String ps=str.trim().split(":")[1];
                str=br.readLine();
                testnumber+=1;
                monkeytest(ps);
                System.out.println(ps+"已跑");
            }
            System.out.println("已跑完,共跑了几个应用的monkey:"+testnumber);
        }
        public static void monkeytest(String packagename) throws Exception
        {
            Process p=Runtime.getRuntime().exec("adb shell monkey -p"+packagename+" --throttle 300  -v 500");
            InputStream in=p.getInputStream();
            InputStreamReader ir=new InputStreamReader(in);
            BufferedReader br=new BufferedReader(ir);
            String str;
            while((str=br.readLine())!=null)
            {
                if(str.indexOf("Monkey finished")!=-1)
                {   
                    System.out.println(str);
                    break;
                }
                else if(str.indexOf("crashed at event")!=-1)
                {
                    System.out.println(packagename+"报错了");
                    break;
                }
            }
            
        }
    
    }
  • 相关阅读:
    数列分块入门 1-8
    最远点对 [线段树+树的直径]
    实验室外的攻防战 UOJ#180 [树状数组]
    二叉搜索树 [四边形不等式优化区间dp]
    树上的等差数列 [树形dp]
    序列 [树状数组+离散化]
    ATcoder1983 BBQ Hard
    8.18日报
    8.17日报
    8.16日报
  • 原文地址:https://www.cnblogs.com/penghong2014/p/4505899.html
Copyright © 2020-2023  润新知