我正在尝试使用 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/