java - 测试 Android 应用程序 - 猴子中止

标签 java android xml testing monkey

我正在尝试使用 monkey 测试一些 Android 应用程序。但是事实证明,使用 Monkey 进行测试并不总是那么直观,因为它并不像人们期望的那样开箱即用。我什至读到其他一些人也遇到了类似的问题,尽管遵循了comments没有明确解决问题。

因此,为了运行 Monkey,我将 LAUNCHER 包含在 AndroidManifest.xml 中:

<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

事实上,由于我正在使用 Android 文档源中的示例之一,将 LunarLander 作为项目名称,因此我尝试了所有可能的命令组合,但没有成功:

$ cd /home/user
$ adb shell monkey -p LunarLander -v 3
$ adb shell monkey -p lunarlander -v 3
$ adb shell monkey -p "LunarLander" -v 3
$ adb shell monkey -p "lunarlander" -v 3

然后,我还将 MONKEY 包含到 AndroidManifest 中:

<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.MONKEY" />
</intent-filter>

然后在命令行中我再次尝试:

$ adb shell monkey -p lunarlander -v 3
:Monkey: seed=1398534940718 count=3
:AllowPackage: LunarLander
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
** No activities found to run, monkey aborted.

同样,我尝试了另一个 suggestion结果相同:

$ adb shell monkey -p lunarlander.client -v 3
:Monkey: seed=1398537535683 count=3
:AllowPackage: lunarlander.client
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
** No activities found to run, monkey aborted.

但是还是不行。有什么想法或建议可能遗漏了什么吗?

最佳答案

您应该使用包名称作为 -p 的参数。

因此,您的命令应该类似于:

adb shell monkey -p com.example.android.lunarlander -v 3

上面com.example.android.lunarlander是SDK自带的LunarLander的包名。

参见 docs更多细节。希望这会有所帮助。

关于java - 测试 Android 应用程序 - 猴子中止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23050483/

相关文章:

android - 如何在 Android TextView 中使用土耳其语字符(如 'ş ç ı ö')?

android - 在android中动态注册/注销广播接收器

java - JNI : Unable to find java class from native method in a callback

php - 从 "Fri, 10 Jun 2016 14:30:38 -0500"转换为 DATETIME

java - 如何显示 float 菜单图标?

java - FBO 纹理显示全黑

java - 在Java中将代表分钟的Double变量添加到Date中

xml - 帮助! Flash 无法从第三方域加载 XML 数据

javascript - Angular JS 和 Spring - 如何过滤 JSON 对象

java - ASM 在 .class 文件中搜索字符串