Testing techniques for Android applications

I've written and shared several documents on Android Test Automation Techniques. The work is still draft and being revised. New updates are published online at http://code.google.com/p/mwta/downloads/list

For Android, personally I use standard JUnit 3.x for my main project http://code.google.com/p/android-daisy-epub-reader/ and focused on using standard Java 5 libraries, etc. for the core functionality which means the tests can be run on the development machine or on the Android platform. In the process of making the code and the tests run on both Java 5 and Android we had to be careful with tests that involve the filesystem to cope with the different folder structures between an Android device and Linux / Windows. We discovered other differences e.g. in the SAX parser - comments are in the source code of the project on the differences we noted.

  • Eclipse + Microsoft Windows: Create a root directory called \sdcard in the same drive as the code e.g. for many people that's C:\sdcard Eclipse effectively maps that to /sdcard which is equivalent to the /sdcard

Interesting Material

Test Automation

http://www.slideshare.net/dtmilano/testing-on-androidhttp://dtmilano.blogspot.com/2009/06/android-testing-on-android-platform.html and more generally http://dtmilano.blogspot.com/search/label/android which includes several articles on automated testing for Android, including sample applications. 
The Android project has some useful material on the topic of automated testing, see http://developer.android.com/guide/topics/testing/testing_android.html

If you're interested in testing via the Android Web Browser then there are two immature implementations. One is part of the WebDriver project - paradoxically hosted as part of the Selenium project http://code.google.com/p/selenium/. The other uses Selenium RC as the following link describes http://mirkonasato.blogspot.com/2010/01/android-browser-testing-with-selenium.html This work will be superseded soon with a rewritten implementation. See http://code.google.com/p/webdriver-mobile-public/ a temporary project that is being supported by Google and will provide well integrated test automation for iPhone, Android and probably other mobile phone platforms in the coming months.

http://www.connorgarvey.com/blog/?cat=3 contains some posts on using mocks to test Android applications. I've not personally tried the examples, but they seem relevant. Robotium, is a fairly recent GUI test automation project, see http://code.google.com/p/robotium Also, there's a dated automation project called Positron that seems to have fallen out of maintenance, however it just might help you implement test automation more easily than starting from scratch.

Test Automation and Continuous Builds