Android _ automated testing tool _ calabash (1)

Source: Internet
Author: User
I found calabash the simplest platform that supports cross platform Mobile Application
Automation testing. Another requirement I had was to have the ability to test applications developed using the mono for Android/IOS frameworks. calabash comes in two flavors calabash-Android and calabash-Ios and
It also had the option to test in the cloud environment through less-painful which apparently had been acquired by xamarin.
This post covers only the details of setting up the test environment for Android apps.


Calabash-android


Calabash supports behavior driven test case development using cucumber. While the high level test case can be written using predefined step definitions in cucumber, more complex steps can be defined in ruby.
Calabash-android provides lot of predefined steps that supports lot of input steps, gestures, touch, snapshot etc.


Installation


  1. The first step is to setup Ruby. At the time of writing this post (July 1st 2013), Ruby
    1.9.3 is the version supported by calabash-android.When installing Ruby make sure the installed directory is set in the Environment path (the last step in the installer prompts for this)
  2. After installing Ruby 1.9.3, install the development kit.Download the correct version of development kit as defined in the ruby
    Download Page
    . For Ruby 1.8.6 to 1.9.3, tdm-32-4.5.2 is
    The suggested devkit.
  3. Follow the detailed instructions as given here
    Setup the devkit. Its basically these steps

    • Extracting the devkit Installer (7-ZIP Archive) to a <install> directory.
    • In the CMD prompt, enterCD <install>, Where <install> is the extracted directory
      In the previous step
    • Then enter,Ruby DK. RB init.This wowould generate the config. yml file which has details about the installed Ruby
      Packages on the system. You can verify that the ruby 1.9.3 is present in this file
    • Then enterRuby DK. RB installTo finalize the devkit Installation
  4. The next step is to install the calabash-android gem. Enter Gem install calabash-androidIn
    The cmd prompt.
Testing the app
Now that the calabash-android framework is installed and setup the next step is to get the app ready to test. calabash-android provides a command utility to easily set up the test project
For the app.
In the CMD prompt, enter the directory in which you want to store the test cases. Let this be the <testdir>.
  • Enter CD <testdir> in
    The cmd prompt.
  • Then typeCalabash-android genTo generate the stub files for the test cases.
    It wocould generate the files in this format

Features

|_support| |_app_installation_hooks.rb| |_app_life_cycle_hooks.rb| |_env.rb|_step_definitions| |_calabash_steps.rb|_my_first.feature
The .feature file will have the cucumber style test case like this
Feature: Login feature  Scenario: As a valid user I can log into my app    When I press "Login"    Then I see "Welcome to MyApp"
Assuming your app has the welcome screen with Login button and the welcome text,        running the login feature test case would succeed without any changes. But typically you 
would want to change the login feature file by providing valid login credentials and ensuring that we see the success message. You can achieve this with the Predefined Steps defined by   the calabash framework. Assuming you have gone through the calabash android framework fair enough and wrote the required steps to validate the login scenario of your app,  you have to sign the .apk file(say com.fun.myapp.apk) with the debug key to test the app.  
The following steps need to be followed to run the test

 
 
  • To help the setup process easier, set the Java SDK path and the Android SDK path in the JAVA_HOME and ANDROID_HOME variables.
  • type the following cmd,

cd %JAVA_HOME%\bin
jarsigner.exe -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore debug.keystore -storepass android -keypass android %~dp0\com.fun.myapp.apk androiddebugkey

  • 3. Allign the .apk file with the following comman

cd %ANDROID_HOME%\tools\
zipalign -v 4 %~dp0\com.fun.myapp.apk %~dp0\com.fun.myapp_allign.apk

  • 4. Run the tests and export the report to .html file and also logging the output in the console

calabash-android run com.fun.myapp_allign.apk --format html --out report.html --format pretty

You can combine all these steps in a batch to make it convenient to run each time. here is a snapshot of the batch file

Now you should be able to see the output in either the report.html file or in the console. Their report format is really cool and it shows the list of features run and what succeeded and failed with color highlights.

http://programmersjunk.blogspot.com/2013/07/android-automation-testing.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.