Calabash is an open-source acceptance testing framework which is used to automate the Android and iOS mobile application. It will support both the Native mobile application and Hybrid mobile application. Calabash used the cucumber working mechanism comprised of Feature file and Step definition(Glue code). Calabash is applicable for mobile application automation using the BDD(Behavior Driven Development) concept, which is nothing but a collaborative tool. Ensure the application got developed based upon the business scenarios available in the feature file given by the business analyst team.
Automation tester going to develop the Step definition(Glue code) for the feature file provided by the business analyst team. This post will explain you to implement the calabash specific automation and tried the iOS version of 10.2 and XCODE 8.2
Please refer the below link to setting up the Calabash in your Mac OS X; I’ve tried with Mac OS Sierra 10.12.3; Driver agent is going to sit inside the mobile and it will trigger all the user actions whatever mentioned in the feature file;
https://github.com/calabash/calabash-ios/wiki/calabash-ios-setup
The main pre-requisites to work with Mac for calabash implementation is nothing but the .APP file is must to kick-start the automation testing task; Source code should be build in the xcode to get he sourcefilename-cal in which the final build filename-cal will be used for automation; All the information is available in the calabash GitHub repo.
I’ve taken the wikipedia source code(.APP) from GitHub based on the below URL for implementing the calabash automation;
https://github.com/wikimedia/wikipedia-ios
Build the code using XCODE to generate the .APP file based on the GitHub instructions. Expected pre-requisites are ready to kick-start the automation testing for wikipedia iOS mobile application;
Generate the feature file skeleton using the below command and you should execute the below list of commands in the project directory;
In a terminal, go to your iOS project; (Steps from GitHub and it is working as expected)
1. cd path-to-my-ios-project (i.e. directory containing .xcodeproj file)
2. Install calabash-cucumber gem (this make take some time because of dependencies)
3. gem install calabash-cucumber
4. calabash-ios setup
Generate a skeleton features folder for your tests
5. calabash-ios gen
Run the generated test – It will run the feature file based on the pre-defined step-definition information;
6. cucumber
I’ve generated the filename-cal(wikipedia-cal.app) ios mobile application using the xcode and used the below code snippet to test the login process functionalities;
Feature: Application should be logged-in successfully
Scenario: Login Scenario
Given the app has launched
Then I wait for the “settings” button to appear
When I touch “settings”
Then I wait for “Log in” to appear
And I touch the login button
Then I wait for “Forgot your password?” to appear
Then I use the native keyboard to enter “gopikannanmailbox” into the “Username” input field
Then I use the native keyboard to enter “XXXXXXX” into the “Password” input field
Then I touch the “Log in” button
Then I wait for “Settings” to appear
And I touch the logged username
Then I wait for “Are you sure you want to log out?” to appear
And I touch the log out button
Then I wait for “Log in” to appear
Calabash is supporting two different approaches of Pre-defined steps and custom steps;
Pre-defines steps is nothing but the keyword driven and it is already built inside the framework for triggering various user actions based on the below URL;
https://github.com/calabash/calabash-ios/wiki/02-Predefined-steps
And custom steps is used to create your own glue code for performing various user actions based on the below URL;
https://github.com/calabash/calabash-ios/wiki/03-Writing-custom-steps
I’ve created the below custom steps under the step-definitions(Glue code) for handling the steps(user action) in the feature file;
And(/^I touch the login button$/) do
sleep(2)
query(“label index:0”)
touch(“label index:0”)
end
And(/^I touch the logged username$/) do
sleep(2)
touch(“label {text BEGINSWITH ‘Logged’}”)
end
And(/^I touch the log out button$/) do
sleep(2)
touch(query(“all view marked:’Log out'”))
end
After the executing the calabash feature file using the command “cucumber” in the MAc terminal, steps got executed and shown the expected test results with the appropriate test steps and scenario information.
Please refer the below video URL for your better understanding about the execution part;
We are going to see the reports customisation in calabash implementation in the forthcoming posting 😉