I'm trying to stress test my android application using the monkey exercise tool.
By default the tool will exercise activities having category Intent.CATEGORY_LAUNCHER
or Intent.CATEGORY_MONKEY
according to the doc.
package="my.android"
<activity android:name=".activities.MyApp">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".activities.MyScreen">
<intent-filter>
<category android:name="android.intent.category.MONKEY"/>
</intent-filter>
</activity>
<activity android:name=".activities.MySettings"/>
I do not want MySettings to be tested by Monkey.
In my real case, this is because that activity does the logout. So after logout there is no way to login back in order to keep testing the rest of the screens which is the whole idea of the test.
./adb shell monkey -p my.android -v 500
:Monkey: seed=0 count=500
:AllowPackage: my.android
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
..
// Allowing start of Intent { cmp=my.android/.activities.MySettings} in package my.android
..
It should be rejecting instead of allowing I guess. Any idea how to avoid the monkey to get into activities I don't want to?
The way I've handled this is by adding the following into onCreate(...) of the activities that you do not want the monkey to test:
if (ActivityManager.isUserAMonkey()) {
finish();
}
That way the activity immediately exits if it is being tested by a monkey.