How to Combine Cucumber with Mobile Test Automation Frameworks

(Last Updated On: 8 Dec 2016)

Dear Testdroiders,

Behaviour-Driven Development (BDD) gathers supporters for many obvious reasons as it is readable (by everyone), understandable (across teams and functions) and accountable (metric-driven for success/failures). Cucumber is a great example of optimized tool/framework to create such tests. This allows basically anyone (developers, QA, testers etc.) to write specifications in any spoken language that then gets executed as automated tests against mobile app(s). Furthermore, this sort of BDD approach incorporates the main standards of test-driven development (TDD) and provides a shared view and process for collaboration between all stakeholders.

Let’s look how to setup Cucumber and how to combine it for some standard test automation frameworks (Appium / Selenium).

Download Our Tutorial to Master Cucumber/Calabash for Mobile App Testing.


Cucumber for Test Automation

Cucumber is a neat tool that developers can use to test their stuff. In mobile context, Cucumber is also usable and for example is used with Calabash. Basically, Cucumber can run automated acceptance tests written in a behavior-driven development (BDD) style and is available with Ruby. In addition, there are other Cucumber projects available for some other platforms/programming languages, but we’ll take a look at Ruby side of things here.

One of the best parts of Cucumber is that it also provides documentation and feature specification for mobile app testing. When the test script is written in understandable language it can also serve as a design, development and test specification – and that’s what makes Cucumber highly usable across functions.

Cucumber can be also used to enable a large-scale test automation with real mobile devices. There are myriad of different test automation frameworks that can get you there instantly, but also combined together with Cucumber. Cucumber behavior-driven development together with one of the best test automation frameworks today – Appium – is a great combination and can help to you automate testing of your apps, write nicely documented specifications and make clarity for test execution.

Prerequisites and Installations

First and foremost, check that your Ruby environment is up-to-date, by using the following terminal line:

$ ruby -v

Things may work pretty well on some older Ruby versions, but to get all the best features and the most stable experience, we recommend using the latest (e.g. 2.2.4 or newer).

RVM – Ruby Version Manager

In case you don’t have or have old version of Ruby or you want to use multiple versions of Ruby, RVM (Ruby Version Manager) is a neat command-line tool which allows quick and easy installations, management of multiple versions and Ruby environments with interpreters and any set of gems. You can simply get it install with these instructions:

$ curl -sSL | bash -s stable
$ rvm install ruby

List of all installed versions of Ruby and set one of those as default one:

$ rvm list
$ rvm --default use 2.1.1

The upgrade of RVM can be done with the following lines:

$ rvm get head
$ rvm autolibs homebrew
$ rvm install ruby

Note that this takes care of Homebrew installation as well. Another alternative to install Homebrew is done as follows:

$ ruby -e "$(curl -fsSL"

After setting up Homebrew you can (and you should) check every now and then if the environment is up to snuff:

$ brew doctor

This should give you Your system is ready to brew but Your Homebrew is outdated is also very common and then keeping Brew up-to-date can be simply done with an update:

$ brew update

Again, it’s worth of checking that it’s Ruby is properly installed by printing out the Ruby version:

$ ruby -v

Update RubyGems and Bundler:

$ gem update --system
$ gem install --no-rdoc --no-ri bundler
$ gem update
$ gem cleanup

Check that RubyGems is >= 2.1.5

$ gem --version

Platform-Specific Tools

Depending on which platform – OS X, Linux or Windows – you’re about to run your tests, you need to setup all required development tools (Xcode for iOS, Android Studio) and other stuff. For detailed instructions on how to setup Appium for any platform, with desired programming language and all dependencies, take a look at our Appium tutorial.

Cucumber Installation

Setting up Cucumber is pretty straightforward.

Create a directory for test example:

$ mkdir cucumber-test
cd cucumber-test

Then create a file under this folder to include the following lines:

source ""
gem "cucumber"
gem "selenium-webdriver"
gem "rspec"
gem "rspec-expectations"

Now, run bundler at the Ruby example directory to install dependencies:

$ bundle install

Now, we have installed everything that it takes to start writing tests and running those. For detailed information on how to write Cucumber tests, you can check from our tutorial. This tutorial gives instructions to write Calabash tests but overall the syntax is the same and tests, steps and features are done the same way.

Happy Testing!

Calabash 101: Basics, Getting Started and Advanced Tips

(Last Updated On: 7 Dec 2016)

Go through the basics of Calabash, how to create proper Calabash tests and how to make the most of them.


By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.