Mobile Software Test Automation: Updating Calabash gems and dependencies

Over the past few months we have gone from creating a project, to implementation in an iOS and android project, to some useful advanced methods.  By now, there is likely an updated Calabash gem with new features and bug fixes that we will want to take advantage of.  So let's get started.

Updating Calabash-Android gem

If you took my advice in the early stages of the project and decided to manage dependencies with bundler, this is where it will pay off.  Updating the calabash-android gem and dependencies is extremely simple.  First, we will need to find the calabash-android repo on GitHub and look for the latest stable version.  It may also be a good idea to view the change-log for this project so you know what to expect.  There have been changes in the past that required a good size refactor for depreciated methods and such, so don't blindly update and hope it always works out.  Now that we know what version we are updating to, open up the Gemfile document in your project folder.  For the 'calabash-android' gem, update the version number to the version you desire, and hit save.  Once this is done, open up your terminal, navigate to your project folder, and run:

$ bundle update

The output should look something like this:


That's all there is to it!  It may be a good idea to run a smoke test to make sure that the update didn't have some unintended consequences before relying on it in a CI environment.  Now we can safely assume that for minor version updates, there likely won't be any breaking changes, so if you want to avoid this hassle for updating minor versions, update your gemfile like this:

gem 'calabash-android', '~> 0.5.14'

This is essentially saying, update all the minor versions (the 3rd number), but not the major versions.  Basically, greater than or equal to 0.5.14 and less than 0.6.0.

Updating Calabash-ios gem

If you remember, setting up the iOS project was a little bit more involved, and as such, there are a few more steps required to update the gem as well.

update the gemfile

The first step is to update the gemfile with appropriate version as we did for android.  Then, in the terminal, inside your project folder, run:

$ bundle update

download the calabash framework

Next, in the terminal, navigate to the directory where your existing calabash.framework is located.  Depending on how you set everything up, it will likely be inside your iOS project's folder.  First, go ahead and check the current calabash version and make note of the result.  In the iOS project directory, run:

$ calabash-ios version

Then, you will want to download the framework with the following command:

$ calabash-ios download

You will see a message asking if you want to delete the current framework and replace with the latest matching version.  Type "y" to proceed.  It will look something like this:


Now, go ahead and check the calabash-ios version again.  It should be the version you specified in the gemfile. 

clean the project and remove old builds

Next, open up your iOS project in Xcode and do a deep clean of the project.  This can be accomplished by going to the "Product" dropdown, hold the option (alt) key and select "Clean Build Folder", or you could use the shortcut keys "shift + option + command + k". 

You will also want to remove the old app builds from physical devices and simulators.  You will have to remove the app builds from physical devices manually, or with some third party tools that we will discuss when we get into the CI discussion.  Resetting the simulators is easy, by running:

$ calabash-ios sim reset

rebuild the project and verify server version

Now it's time to rebuild the project.  To make it easier to verify that the latest version of calabash server is embedded into your app, go ahead and rebuild to a simulator.  With the app running in the simulator, type the following in the terminal:

$ curl http://localhost:37265/version

You will get a JSON response that includes the version number.  Check this against the version that you downloaded to make sure that it is properly embedded.  Alternatively, with the newer versions of calabash-ios, you could also view the console target output in Xcode when you built the app to see the calabsh version.  

Wrapping up

You're all set!  Hopefully this was a fairly painless exercise in updating the calabash gems.  Next week we will work through structuring our project with tags, which leads up to a multi-part series on setting up a Jenkins CI server and integrating our test suite into it.