This document provides an overview of test automation using Cucumber and Calabash. It discusses using Cucumber to write automated test specifications in plain language and Calabash to execute those tests on Android apps. It outlines the environments, tools, and basic steps needed to get started, including installing Ruby and DevKit, creating Cucumber feature files, and using Calabash APIs to automate user interactions like tapping, entering text, and scrolling. The document also explains how to run tests on an Android app and generate an HTML report of the results.
Introduction of Test Automation using Cucumber and Calabash. Overview of contents including: testing methodologies, environment setups, and implementation.
Discussion on unit testing, integration testing, and regression testing, highlighting their definitions and importance in the software development lifecycle.
Comparison of manual and automated testing emphasizing cost, time-efficiency, reusability, and error risk. Automated testing allows broader test coverage with less user error.
Details of Cucumber as a BDD framework for writing specifications in natural language, allowing for user behavior-driven tests with easily readable scenarios.
Introduction to Calabash as a cross-platform testing tool supporting both Android and iOS testing, with BDD acceptance testing capabilities and usage on simulators.
Steps for defining behavior in Ruby, running tests, observing failures and successes, emphasizing the iterative nature of test development.
Instructions for installing Ruby, DevKit, Rails, and Calabash-Android, ensuring successful setup for environment readiness.
Procedure for preparing Cucumber test cases, emphasizing the structure of test feature files and defining scenarios using 'Given', 'When', and 'Then'.
Overview of basic API functions in test automation such as touch, enter text, tap, and scroll with examples, crucial for interaction testing of mobile applications.
Testing
Unit Testing
–A software testing method by which individual units of source code
Integration Testing
– A phase in software testing in which individual software modules are
combined and tested as a group.
Regression Testing
– A type of software testing that seeks to uncover new software bugs, or
regressions
4.
Manual and Automatic
ManualAutomatic
High Effort and Cost requirements Low Effort and Cost requirements
Time consuming
Quick, allows test engineers to focus on
functional areas
Tests are not reusable
Complete reusability based on type of
implementation
Mostly used for integration tests
Can be used for any tests including load,
sanity, system, etc
Risk of human errors Script validates all areas once tested
Cucumber
A frameworkfor writing software specifications
A tool for executing those specifications
– Specifications are written in a readable language that is close to
natural language.
– Scenarios – user behavior driven tests
– Steps – combine mobile operation and logic
7.
Calabash
A tool
–Predefined and custom steps
– Reuse of tests across platform possible
– For BDD-style acceptance testing
Run on physical devices or simulators
Support for webview
Ruby based
Cross-platform mobile testing tool
– Cucumber: Android or IOS testing
8.
Implement Steps
Describe behaviorin plain text
Write a step definition in Ruby
Run and watch it fail Run and watch it success
Write code to make the step pass
9.
Describe behavior inplain text
Feature
– Descriptions
Scenario
– Descriptions
– Preconditions
– Steps
Given
When
And
But
Then
Ruby Installer
DownloadRubyInstaller
Install
– Check the option named “Add Ruby executables to your PATH”
– Test it
Using “ruby –v” on cmd window
– Observer
Show “ruby 2.0.0p353 (2013-11-22) [x64-mingw32]”is success.
15.
DevKit
Download DevKitin a folder which you want to save
– For Instance: D:DevKit
Navigate the folder on cmd window
– Using “ruby de.rb init”
Check the file named config.yml is existent
Using “ruby dk.rb install”on cmd window
16.
Rails and Calabash-Android
Using “gem update --system” and “gem install rails --no-ri --no-
rdoc”on cmd window
Install Rails
– Using “gem install rails --no-ri --no-rdoc”
Test it
– Using “rails –v” on cmd window
It is successful to show “Rails 4.0.2”
Using “gem install calabash-android” on cmd window
17.
Prepare Test Cases
Create a Cucumber skeleton
in your Android project
– Using “calabash-android gen”
on cmd window
Create a *.feature file
– That is a test case file including
features, function descriptions or
scenarios.
18.
Given, When andThen
Given
– your preconditions
When
– describe the key action
Then
– observe outcomes or an assertion
And, But
– Using it if you have several givens, whens or thens.
19.
Basic API
Findout a view - Query(uiquery, *args)
– You can find views and other application objects, and make assertions
about them or extract data from them, and query returns an array of
its results.
For instance:
20.
Basic API
Touch- touch(uiquery, options={})
– Touches a view found by performing the query uiquery.
For instance:
21.
Basic API
Enteringtext - enter_text(uiquery, text, options={})
– Taps the first element returned by uiquery, then enters text into the
view.
For instance:
22.
Basic API
Tap- tap_when_element_exists(uiquery, options={})
– Waits for an element and taps it when it appears on screen. It raises an
exception if the element doesn't appear within the timeout.
For instance:
23.
Basic API
Scroll- scroll_down and scroll_up
– Scrolls the first instance of 'android.widget.ScrollView' either
downwards or upwards.
For instance:
24.
Run your APPand generate a report
Using “calabash-android run apkName.apk –format
html –out reports.html” on cmd window