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

Sop*_*lor 4 java xml testing android monkey

我正在尝试使用猴子测试一些Android应用程序.但是使用Monkey进行测试已经证明并不总是如此直观,因为它不像人们所期望的那样开箱即用.我甚至读过其他一些类似问题的人,尽管这些评论没有明确解决问题.

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

<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

事实上,当我使用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
Run Code Online (Sandbox Code Playgroud)

然后,我还将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>
Run Code Online (Sandbox Code Playgroud)

在命令行中我再次尝试:

$ 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.
Run Code Online (Sandbox Code Playgroud)

同样我想这等建议,同样的结果:

$ 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.
Run Code Online (Sandbox Code Playgroud)

但它仍然无效.有什么想法或建议可能缺少什么?

ozb*_*bek 6

您应该使用包名作为参数-p.

所以,你的命令应该类似于:

adb shell monkey -p com.example.android.lunarlander -v 3
Run Code Online (Sandbox Code Playgroud)

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

有关更多详细信息,请参阅文档.希望这可以帮助.