mercredi 28 novembre 2018

Preventing the Android Monkey from starting Activities

I have an app that I want to Monkey Test with the Android ADB Monkey Exerciser. I want the "monkey" to mess around in a list view of Items, but prevent it from going to the payment/order activity. I thought it would be enough adding the Monkey Category in the activity intent-filter to all activities except the payment/order activity. But the Monkey still manages to click it's way in to the Payment/Order Activity.

The package parameter works as expected, but not the Category param.

-c main-category

If you specify one or more categories this way, the Monkey will only allow the system to visit activities that are listed with one of the specified categories. If you don't specify any categories, the Monkey will select activities listed with the category Intent.CATEGORY_LAUNCHER or Intent.CATEGORY_MONKEY. To specify multiple categories, use the -c option multiple times — one -c option per category.

https://developer.android.com/studio/test/monkey

This is how my Activities with the Monkey category typically looks like. My problem is that the Monkey Allows start of Activities without the Monkey Category.

<activity
    android:name=".activity.SomeActivity"
    android:parentActivityName=".activity.drawer.ParentActivity">
  <intent-filter>
    <category android:name="android.intent.category.MONKEY"/>
  </intent-filter>
</activity>

This is how my ADB command typically looks like.

monkey -p <my.package.name> -c android.intent.category.MONKEY -v -v 200

After reading the Monkey source code my understanding is that the category Monkey only works when the Monkey tries to start an Main Activity with an Implicit Intent, and that the categories is ignored when the app is starting Explicit Intents within the app. https://android.googlesource.com/platform/development/+/master/cmds/monkey/src/com/android/commands/monkey/Monkey.java

Aucun commentaire:

Enregistrer un commentaire