Android testing is hard, which is probably why people don’t do it!

So, over the past few weeks I have been trying to automate the testing of my application. Every time I attempt to do something I come across a pretty major hurdle.

I am currently producing an application on the Android platform that includes a Google v2 Map View, Umano / SlidingUpPanelLayout, Sensors, Camera, REST calls etc. So, far my experience of test frameworks out there (Espresso, Robolectric, Robotium) all seem to work for standard apps with list views, text fields, launching new activities but when we start to use Maps etc. I come to a grinding halt.

Writing automated tests isn’t easy the first time round but Android seems to be harder than writing plain tests for Java Web Applications. It makes me question whether it is worth the effort!

My experience with Maps so far have been one of continued pain. The first challenge is getting the Maps to work on an emulator as by default this isn’t supported. I have had to jump through many hoops by downloading the APKs (com.android.vending-20140218.apk & com.google.android.gms-20140218.apk) from various sources to get the basic maps working. Then when this is installed I get continuous error messages popping up. Genymotion looks like a better solution and has a very good emulator (which costs) but even that isn’t pain free.

Testing anything with the mapping again is challenging. My application places markers on the map and I would like to have a test that taps on these markers however, just isn’t possible. I have had to work around this by keeping track of the markers in the test code and calling the onMarkerClick method using a cached Marker object!

Espresso in general has been a great framework to write a majority of automated tests but it does rely heavily on writing custom matchers and actions for controls like map views etc.

In summary, Android testing is tough and anyone that writes Android tests deserves a medal!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s