An Overview of Calabash Android
This post describes Calabash Android in some technical detail. It will give you an architectural overview of Calabash Android and a resume of the functional testing tools available for Android. It assumes that you are familiar with Cucumber and Android development.
- For an introduction to Calabash and LessPainful (and some info on Cucumber), please read Calabash: Functional Testing for Mobile Apps.
- Instructions for how to use Calabash in your Android project can be found on Github.
Calabash Android Architecture
When a Calabash Android test is executed both your local computer and a device is involved. The device might be an emulator or an actual physical device. The setup looks like this:
Features. The feature files describe the user-stories you want to test. You can test one or more features in one test run.
Step Definitions. Calabash Android comes with a set of predefined step which you can find here. These steps are generic and made to get you up and running fast. When you get more into Calabash you can implement your own custom steps that use the business terms your project uses like
I transfer money to my spendings accountor
I play "Never Gonna Give You Up".
Your app. You don’t have to make modifications to your app before testing it.
Instrumentation Test Server. This is another app that will be installed and executed the device. This app is based on
ActivityInstrumentationTestCase2from the Android SDK. It is generated by the Calabash Android framework.
Functional Testing tools for Android
The Android SDK comes with a testing framework located in the
android.test package. According to Google it is easy to use. However, I’m pretty sure that the person who wrote that either never wrote and maintained a test using
ActivityInstrumentationTestCase2 or has totally misunderstood the “easy to use” concept. :–)
When Renas Reda created Robotium things became a lot easier. Robotium is a utility that handles a lot of the small details you really don’t want to be concerned about in a functional test. You are still writing your test using Java and JUnit but a lot of the very annoying things from vanilla Android testing is now taking care of and don’t pollute your tests. Today all the Android projects that I know of that do any kind of testing use Robotium or Calabash. So if you are still fighting
android.test and want to clean up your tests you should give Robotium a try and send Renas a happy thought.
Even when using Robotium my experience from several large Android projects is that writing functional testing in Java is just wrong. Over time, the ever growing test suite becomes takes more and more resources to maintain mainly because the readability goes down. But hey! Why wouldn’t it be like that? That is exactly the same experience we had when writing functional test for websites!
Calabash uses Robotium as a library to make the interaction with the tested app as robust as possible while letting the developer or tester write precise and clean test that are easy to maintain.
And that’s why you should give Calabash Android a try.
Testing Hybrid Apps
If you are using Appcelerator, PhoneGap, Sencha Touch or any of the other frameworks for creating hybrid apps. You should really take a look at Calabash. By using the same Cucumber interface as for a native app you can test HTML 5 part of your application. Testing webviews has not been posible with the currently available test frameworks. But with Calabash you can!
Let me know at firstname.lastname@example.org or @jonasmaturana.