我的包名为com.mywebsite.banana.
>我想要种子,所以测试是可重复的:-s 13
>我希望有一个相当低级别的冗长:-v
>我想运行500个伪随机命令:500
我这样叫猴子:
adb shell monkey -s 13 -p com.mywebsite.banana -v 500
我的输出:
:Monkey: seed=13 count=500 :IncludeCategory: android.intent.category.LAUNCHER :IncludeCategory: android.intent.category.MONKEY No activities found to run,monkey aborted
我的AndroidManifest.xml中有这个:
<categoy android:name="android.intent.category.LAUNCHER"/>
我究竟做错了什么?在运行猴子之前,我需要添加到我的应用程序中吗?主要活动位于com.mywebsite.banana – 是传递的正确路径,还是应该一直到这样的活动:com.mywebsite.banana.activityName?
从我所读到的,似乎我正确地做到了这一点:
> http://dnlkntt.wordpress.com/2014/04/01/how-to-stress-test-your-android-app-with-monkey/
> http://www.tutorialspoint.com/android/android_testing.htm
> http://hariniachala.blogspot.com/2011/09/android-application-ui-testing-with.html
编辑
尝试1:
adb shell monkey -p com.mywebsite.banana -c intent.CATEGORY_LAUNCHER -v 500
结果1:
:Monkey: seed=13 count=500 :AllowPackage: com.mywebsite.banana :IncludeCategory: intent.CATEGORY_LAUNCHER // Warning: no activities found for category intent.CATEGORY_LAUNCHER ** No activities found to run,monkey aborted
尝试2:
adb shell monkey -p com.mywebsite.banana -c android.intent.category.MONKEY -v 500
结果2:
:Monkey: seed=13 count=500 :AllowPackage: com.mywebsite.banana :IncludeCategory: android.intent.category.MONKEY No activities found to run,monkey aborted
尝试3:
adb shell monkey -p com.mywebsite.banana -c android.intent.category.LAUNCHER -c android.intent.category.MONKEY -v 500
结果3:
:Monkey: seed=13 count=500 :AllowPackage: com.mywebsite.banana :IncludeCategory: android.intent.category.LAUNCHER :IncludeCategory: android.intent.category.MONKEY No activities found to run,monkey aborted
一些清单:
<activity android:name="com.mywebsite.banana.FRCActivity" android:launchMode="singleTask" android:configChanges="orientation|screenSize" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="none" /> <category android:name="android.intent.category.MONKEY"/> </intent-filter> </activity>
还试过这个版本的清单,没有变化:
<activity android:name="com.mywebsite.banana.FRCActivity" android:launchMode="singleTask" android:configChanges="orientation|screenSize" android:label="@string/app_name" > <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> </activity>
解决方法
好!我想出来了.显示的错误确实是正确的:
** No activities found to run,monkey aborted
这意味着我使用的包名称不正确.我凝视着,凝视着,盯着看,最后我的同事提到我们的构建系统在将其推送到设备之前更改了包的名称
因此,如果您收到此错误,请确保您确实知道您的包的名称是什么.
所以,最终的命令是这样的:
$adb shell monkey -p com.mywebsite.banana.newname -v 5
顺便说一句,这个monkey命令的正确输出如下所示:
:Monkey: seed=1418671144561 count=5 :AllowPackage: com.mywebsite.banana.newname :IncludeCategory: android.intent.category.LAUNCHER :IncludeCategory: android.intent.category.MONKEY // Event percentages: // 0: 15.0% // 1: 10.0% // 2: 2.0% // 3: 15.0% // 4: -0.0% // 5: 25.0% // 6: 15.0% // 7: 2.0% // 8: 2.0% // 9: 1.0% // 10: 13.0% :Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.mywebsite.banana.newname/com.mywebsite.banana.MyActivity;end // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.mywebsite.banana.newname/com.mywebsite.banana.MyActivity } in package com.mywebsite.banana.newname Events injected: 5 :Sending rotation degree=0,persist=false :Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0 ## Network stats: elapsed time=175ms (0ms mobile,0ms wifi,175ms not connected) // Monkey finished
最后一点说明:我不需要将android.intent.category.MONKEY添加到我的AndroidManifest.xml文件中!