Automating android application using robotium is simple but it is really missing cucumber feature test. LessPainful open sourced their functional testing tool for Android and iOS mobile apps based on cucumber tool, which is called Calabash. There are separate repository for android and iPhone.
Installation of calabash-android is very simple and explained here. Once you installed calabash-android, modify build.properties file and add details of your android application (Make sure that the application has INTERNET permission).
I have used the sample notepad application from android SDK and changed the build.properties file like below.
tested.package_name=com.example.android.notepad
tested.main_activity=com.example.android.notepad.NotesList
tested.project.apk=NotePad.apk
android.api.level=15 # using Android 4
key.store=${user.home}/.android/debug.keystore
key.store.password=android
key.alias=androiddebugkey
key.alias.password=android
The cucumber feature files need to be added into features directory. If you are following imperative style coding in cucumber (each step level) then most of the basic steps are already presented in the features/step_definitionsdirectory. You can add custom steps in the same directory in order to achieve declarative style steps. I have added both type of tests (refer the below screenshot).
Run android emulator and run your cucumber test using ant clean test. The test result will be available in the console. It is also possible to run cucumber command, instead of ant. If you are running cucumber command there is no need to update the build.properties file. See the below command for running cucumber directly.
PACKAGE_NAME=com.example.android.notepad TEST_PACKAGE_NAME=com.example.android.notepad.test APP_PATH=NotePad.apk TEST_APP_PATH=bin/Test.apk TEST_SERVER_PORT=34777 cucumber
This is the html result generated by cucumber.
You can also run your Calabash tests on multiple devices using LessPainful.com.
Update: The latest version of calabash-android setup is really simple.
- Install the gem : gem install calabash-android
- Run calabash-android gen : to generate feature directory and support filess, you can run this command from any directory( application source code is not required)
- Run calabash-android run <<apkfile_path>>




