返回顶部
首页 > 资讯 > 移动开发 >Android测试之Monkey
  • 483
分享到

Android测试之Monkey

Android 2022-06-06 12:06:48 483人浏览 安东尼
摘要

  Android官方对Monkey进行了简单介绍,网上也有不错的翻译。这部分直接引用官网的原文和网友的翻译。个人理解不同所以觉得有必要把官网原文贴出来。你也可以直接参见h

  Android官方对Monkey进行了简单介绍,网上也有不错的翻译。这部分直接引用官网的原文和网友的翻译。个人理解不同所以觉得有必要把官网原文贴出来。你也可以直接参见https://developer.android.com/tools/help/monkey.html。本文适合android测试人员阅读,欢迎交流讨论。   Monkey是什么   Monkey是可以运行在模拟器里或实际设备中的程序。它向系统发送伪随机的用户事件流(如按键输入、触摸屏输入、手势输入等),实现对正在开发的应用程序进行压力测试。   The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner.   Monkey简介   Monkey是一个命令行工具,可以运行在模拟器里或实际设备中。它向系统发送伪随机的用户事件流,实现对正在开发的应用程序进行压力测试。Monkey包括许多选项,它们大致分为四大类:   · 基本配置选项,如设置尝试的事件数量。   · 运行约束选项,如设置只对单独的一个包进行测试。   · 事件类型和频率。   · 调试选项。   在Monkey运行的时候,它生成事件,并把它们发给系统。同时,Monkey还对测试中的系统进行监测,对下列三种情况进行特殊处理:   · 如果限定了Monkey运行在一个或几个特定的包上,那么它会监测试图转到其它包的操作,并对其进行阻止。   · 如果应用程序崩溃或接收到任何失控异常,Monkey将停止并报错。   · 如果应用程序产生了应用程序不响应(application not responding)的错误,Monkey将会停止并报错。   按照选定的不同级别的反馈信息,在Monkey中还可以看到其执行过程报告和生成的事件。   The Monkey is a command-line tool that that you can run on any emulator instance or on a device. It sends a pseudo-random stream of user events into the system, which acts as a stress test on the application software you are developing.   The Monkey includes a number of options, but they break down into four primary cateGories:   Basic configuration options, such as setting the number of events to attempt.   Operational constraints, such as restricting the test to a single package.   Event types and frequencies.   Debugging options.   When the Monkey runs, it generates events and sends them to the system. It also watches the system under test and looks for three conditions, which it treats specially:   If you have constrained the Monkey to run in one or more specific packages, it watches for attempts to navigate to any other packages, and blocks them.   If your application crashes or receives any sort of unhandled exception, the Monkey will stop and report the error.   If your application generates an application not responding error, the Monkey will stop and report the error.   Depending on the verbosity level you have selected, you will also see reports on the progress of the Monkey and the events being generated.   Monkey的基本用法   可以通过开发机器上的命令行或脚本来启动Monkey。由于Monkey运行在模拟器/设备环境中,所以必须用其环境中的shell来进行启动。可以通过在每条命令前加上adb shell来达到目的,也可以进入Shell后直接输入Monkey命令。基本语法如下:   $ adb shell monkey [options]   如果不指定options,Monkey将以无反馈模式启动,并把事件任意发送到安装在目标环境中的全部包。下面是一个更为典型的命令行示例,它启动指定的应用程序,并向其发送500个伪随机事件:

$ adb shell monkey -p your.package.name -v 500 You can launch the Monkey using a command line on your development Machine or from a script. Because the Monkey runs in the emulator/device environment, you must launch it from a shell in that environment. You can do this by prefacing adb shell to each command, or by entering the shell and entering Monkey commands directly. The basic syntax is: $ adb shell monkey [options] <event-count> With no options specified, the Monkey will launch in a quiet (non-verbose) mode, and will send events to any (and all) packages installed on your target. Here is a more typical command line, which will launch your application and send 500 pseudo-random events to it: $ adb shell monkey -p your.package.name -v 500


--结束END--

本文标题: Android测试之Monkey

本文链接: https://lsjlt.com/news/28720.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作