Search code examples
javaandroidxmltestingmonkey

Testing Android App - Monkey aborted


I am trying to test some Android App using monkey. But using Monkey to testing has proven to not always be so intuitive, as it doesn't work out of the box as someone could expect. I even read that some others incurred in similar problems, although following that comments does not clearly solved the issue.

So, for running Monkey I included the LAUNCHER into the AndroidManifest.xml:

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

In fact, as I am using one of the example from Android documentation source, having LunarLander as the project name, I tried all the possible combinations for the command, but in vain:

$ 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

Then, I also included MONKEY to 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>

And in the command line I tried again:

$ 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.

Equally I tried this other suggestion with the same result:

$ 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.

But still it doesn't work. Any idea or suggestion what might be missing?


Solution

  • You should use the package name as an argument for -p.

    So, your command should look something like:

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

    Above, com.example.android.lunarlander, is the package name of LunarLander that comes with the SDK.

    See the docs for more details. Hope this helps.