zoukankan      html  css  js  c++  java
  • 手机三方应用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;
                }
            }
            
        }
    
    }
  • 相关阅读:
    在Windows Phone应用中使用Google Map替代Bing Map
    《从入门到精通:Windows Phone 7应用开发》
    判断最小割的唯一性
    ASP.NET页面生命周期
    SQL排序
    window.open
    VS2008中英文转换
    asp.net下载文件的常用方法
    TSQL Convert转换时间类型
    TreeView
  • 原文地址:https://www.cnblogs.com/penghong2014/p/4505899.html
Copyright © 2011-2022 走看看