Tuesday, April 23, 2013

How to avoid unstable releases - isUserAMonkey?

*I'm NOT saying that bosses use devices like monkeys or vice versa!
To be honest, this is the least effective way to find bugs. At least if you try to cope with the Activity lifecycle the way you should (read me!). Anyway, it might help find those bugs, your boss would usually find by turning the device a few times, pressing random buttons and... "Force Close". That's what Monkey does.*

You don't have to write any tests for this to work. Instead, you simply install your app as usual (preferably on an emulator) and run the following command from your command line: adb shell monkey -p your.package.name -v 500

I recommend you to tweak this command a little bit, like this: adb shell monkey -p your.package.name --pct-syskeys 0 -p your.package.name.again -v 500

What this does:
  1. --pct-syskeys 0 prohibits keys like Home (which you don't really want to get pressed during a test...)
  2. -p your.package.name.again restricts the Monkey to only interact with Activities in your package
By the way, you can change the number of "events" (keypresses, touch events, etc) the Monkey produces by changing the number at the very end of the command.

You can find more parameters for this command here: http://developer.android.com/tools/help/monkey.html

A Monkey sittin in a cloud

Now you want to automate the whole process, right? Of course you do. apkudo (or APKUDO?) is a service, which has 250 different Android devices, and - more importantly - at least 250 Monkeys which test your app the way we just did locally. The price for testing your app on 250 (read, all?) different Android devices? It's free. Crazy stuff.
You don't even have to sign up - just sign in using your Google account, upload your APK. The Monkeys do the rest for you.

Unfortunately, their user interface is quite unintuitive if you ask me. It took me a while to figure out where I can find the stuff I want to see, but you get used to it...

One more thing: quite a few of the errors reported by APKudo were errors while installing the app (timeouts, container errors, etc). I've already told apkUDO about this, but they haven't replied so far...