General installation steps
You can find the general installation guide for Calabash for Android here:
https://github.com/calabash/calabash-android/blob/master/documentation/installation.md
Once all the needed tools are installed (Ruby and Android SDK), run the following command:
$ sudo gem install calabash-android
The calabash-android
command should be available in the path.
Create a new test
$ mkdir new-calabash-test
$ cd new-calabash-test
$ calabash-android gen
This generates a new feature directory inside the new-calabash-test directory. The feature directory contains my_first.feature-file, step_definitions-directory, and support-directory. For a simple test only, edit my_first.feature-file. Here is the list of predefined steps required: https://github.com/calabash/calabash-android/blob/master/ruby-gem/lib/calabash-android/canned_steps.md
Run the first test
Here is an example of a Calabash test:
Feature: Click items
Scenario: Run whole app
When I press the view with id "radio0"
Then I wait
Then I press the view with id "radio1"
Then I wait
Then I press the view with id "radio2"
Then I take a screenshot
Then I wait
Then I enter text "Hello Calabash" into the field with id "editText1"
Then I take a screenshot
Then I wait
Then I press the view with id "button1"
Then I wait
Then I take a screenshot
Then I go back
Then I wait
Then I press the view with id "radio1"
Then I wait
Then I press the view with id "button1"
Then I wait
Then I take a screenshot
![]() |
Calabash requires the application to have the INTERNET permission enabled in the AndroidManifest.xml file. |
If the application has not been signed yet, you can do it with Calabash:
$ calabash-android resign {path-to-apk}
Now, you should be ready to run the Calabash test locally. Go to new-calabash-test-directory and run:
$ calabash-android run {path-to-apk}
The output should look as follows:
Feature: Click items
Scenario: Run whole app # features/my_first.feature:3
2485 KB/s (554161 bytes in 0.217s)
2282 KB/s (100963 bytes in 0.043s)
When I press the view with id "radio0" # calabash-android-0.4.14/lib/calabash-android/steps/press_button_steps.rb:13
Then I wait # calabash-android-0.4.14/lib/calabash-android/steps/progress_steps.rb:5
Then I press the view with id "radio1" # calabash-android-0.4.14/lib/calabash-android/steps/press_button_steps.rb:13
Then I wait # calabash-android-0.4.14/lib/calabash-android/steps/progress_steps.rb:5
Then I press the view with id "radio2" # calabash-android-0.4.14/lib/calabash-android/steps/press_button_steps.rb:13
Then I take a screenshot # calabash-android-0.4.14/lib/calabash-android/steps/screenshot_steps.rb:9
Then I wait # calabash-android-0.4.14/lib/calabash-android/steps/progress_steps.rb:5
Then I enter text "Hello Calabash" into the field with id "editText1" # calabash-android-0.4.14/lib/calabash-android/steps/enter_text_steps.rb:25
Then I take a screenshot # calabash-android-0.4.14/lib/calabash-android/steps/screenshot_steps.rb:9
Then I wait # calabash-android-0.4.14/lib/calabash-android/steps/progress_steps.rb:5
Then I press the view with id "button1" # calabash-android-0.4.14/lib/calabash-android/steps/press_button_steps.rb:13
Then I wait # calabash-android-0.4.14/lib/calabash-android/steps/progress_steps.rb:5
Then I take a screenshot # calabash-android-0.4.14/lib/calabash-android/steps/screenshot_steps.rb:9
Then I go back # calabash-android-0.4.14/lib/calabash-android/steps/navigation_steps.rb:1
Then I wait # calabash-android-0.4.14/lib/calabash-android/steps/progress_steps.rb:5
Then I press the view with id "radio1" # calabash-android-0.4.14/lib/calabash-android/steps/press_button_steps.rb:13
Then I wait # calabash-android-0.4.14/lib/calabash-android/steps/progress_steps.rb:5
Then I press the view with id "button1" # calabash-android-0.4.14/lib/calabash-android/steps/press_button_steps.rb:13
Then I wait # calabash-android-0.4.14/lib/calabash-android/steps/progress_steps.rb:5
Then I take a screenshot # calabash-android-0.4.14/lib/calabash-android/steps/screenshot_steps.rb:9
1 scenario (1 passed)
20 steps (20 passed)
0m47.002s
If your test takes screenshots, they should be stored as png-files in new-calabash-test-directory.
Run Calabash Android test in BitBar Testing
The following steps will help you get your Calabash tests up and running on over 250 Android devices:
-
Log in to BitBar Testing.
-
Create a new project.
-
Upload your .apk application.
-
Create a zip package from your feature directory.
-
Upload the test zip package.
-
Select devices.
-
Check advanced configurations.
-
Run the project.
-
Verify the results.