blog

Let's talk about testing

Mobile test automation in 3 simple steps

This entry is part 4 of 10 in the series Test Automation

Introduction

 

Hi Again,

In this post we would like to explain a bit more about the mobile test automation that we are using here at spriteCloud. The past years we have seen that the mix of cucumber with selenium webdriver has been extremely powerful. This setup allows for test automation that is, besides easy to setup and maintain once you get the hang of it, understandable and easy to expand for any stakeholder in your project. We are using this same setup now for testing native mobile applications and it works like a charm!

We will start with mobile test automation for android. For this test automation we are using calabash-android which is basically a mix of cucumber with robotium under the hood…

 

Step 1 – Setup your environment

 

First, you need to get all your libraries sorted. This should be fairly easy to achieve since you just need to;
– Install ruby if you dont have it installed already
– install calabash-android:

gem install calabash-android

Depending on your testscenarios you might need some more libraries but you’ll get there along the way.

Now, make a root folder where you want to store your test automation files and create the skeleton files for your test automation by running the following command:

calabash-android gen

This step is also well explained at the installation section of the calabash-android project

 

Step 2 – Use the default debug build key and signature

 

Well done, you’ve got all the requirements to build your test automation suite. Well, you’d need an app as well. Plus you’d need to sign it and use the exact same key and credentials for your calabash testserver, else it wont be able to install and run it on the emulator or device. Although creating a key and use it to sign your apk is all explained on the android developers pages, the easiest would be to just have the test automation use the default debug key that android uses (which is being generated when you build your application). The only thing you need todo for that is to create/edit a .calabash_settings file in the root directory of your test automation folder and point to that keystore file. For example:

{
  "package_name":"debug.keystore",
  "api_level":"14",
  "keystore_location":"./features/support/debug.keystore",
  "keystore_password":"android",
  "keystore_alias":"androiddebugkey",
  "keystore_alias_password":"android"
}

NOTE: api_level obviously depends on what android platform you are building your app on so make sure to have that set correctly.

 

Step 3 – Test the test setup

 

There you go. Now your test setup should be all set. You dont have any test scenarios yet, but running calabash should show you if you have everything set up properly!

calabash-android run <link_to_your_android_debug_build.apk>

In the features folder you can place your scenarios. Information about creating feature files can be found in our blog about cucumber and web testing.

 

For iOS you say?…

 

Yes, there is a gem called calabash-ios. This is working somewhat different since there is no robotium under the hood. Its too much work to cover that here, so hopefully we are able to give some more information for you at a later stage.

‘Happy test-automationing’!


  • Mickael

    Hello,

    When I was trying to run the ‘calabash-android run myapp.apk’ I was getting:

    calabash-android:28:in `raise_if_android_home_not_set’: Please set the ANDROID_HOME environment variable (Runtime Error)

    I’m using windows 7, so then I set that variable to:

    set ANDROID_HOME=”C:Program FilesAndroidandroid-sdk”

    but I’m now getting:

    “No test server found for this combination of app and calabash version. Recreating test server.
    D:/workspace/calabash/android/vendor/bundle/ruby/1.9.1/gems/calabash-android-0.3.8/bin/calabash-android-build.rb:9:in `calabash_build’: No Android SDK found in “C:/Program Files/Android/android-sdk”/p
    latforms/ (RuntimeError)”

    Any idea where the problem could be and how to overcome it?

    Many thanks…

    • Hi Mickael,

      Thanks for your comment. The error is most likely because it cannot find the android SDK, which is required for running calabash.
      You can get the sdk from: http://developer.android.com/sdk/index.html
      Also, sure the ANDROID_HOME path points to the correct location. You can verify this by typing:> echo $ANDROID_HOME

      Cheers!

Reputation. Meet spriteCloud

Find out today why startups, SMBs, enterprises, brands, digital agencies, e-commerce, and mobile clients turn to spriteCloud to help improve their customer experiences. And their reputation. With complete range of QA services, we provide a full service that includes test planning, functional testing, test automation, performance testing, consultancy, mobile testing, and security testing. We even have a test lab — open to all our clients to use — with a full range of devices and platforms.

Discover how our process can boost your reputation.