14
CALABASH - JENKINS - GIT AUTOMATED TESTING

Calabash automated test

Embed Size (px)

Citation preview

Page 1: Calabash automated test

CALABASH - JENKINS - GIT

AUTOMATED TESTING

Page 2: Calabash automated test

ALL YOU NEED IS HERE

HOW TO TEST ON LOCAL DEVICE?

https://github.com/calabash/calabash-android

Page 3: Calabash automated test

CUCUMBER IS FOR BEHAVIOUR-DRIVEN DEVELOPMENT

Someone on Cucumber Website

Page 4: Calabash automated test

CUCUMBER

CUCUMBER SCRIPT▸ Here’s the example for

cucumber script for create scenario testing in human level (i mean it :) )

▸ If anyone had experience with ruby this script already used by ruby on rails testing method with rspec framework

▸ This cucumber will call and parsed on real ruby files helper with regex method

Page 5: Calabash automated test

CUCUMBER

▸ Rules cucumber script

▸ For advance use please check

CUCUMBER SCRIPT

Ex. Touch somethingThen I touch “login” buttonThen = Represent do this line after doing something for action in first time you can use “Given” with initial condition ex. (Given I am on “login” page) while check if “login” page really present on screentouch = Represent the action of this part of scenario it can be “fill”, “swipe”, “wait”, “scroll”, “rotate”, etc.login = Represent the target for the action you can get this id from query all element in screenbutton = Represent the element to test by the action

* Make sure create make sense action for test the scenario because you can use this for random purpose

https://github.com/calabash/calabash-ios/wiki/02-Predefined-steps

Page 6: Calabash automated test

CUCUMBER

ACCESSING THE ID OF VIEW PRESENTWildan-Garviandi:~/tmp/android$ calabash-android console login.apkirb(main):001:0> reinstall_apps=> nilirb(main):002:0> start_test_server_in_background=> nil

To get the id of view of present view you can do it via terminal

The result from query all views is :irb(main):001:0> query("button")[{"id"=>"login_button", "enabled"=>true, "contentDescription"=>nil, "text"=>"Login", "qualified_class"=>"android.widget.Button", "frame"=>{"y"=>322, "height"=>73, "width"=>84, "x"=>135}, "description"=>"android.widget.Button@40584908", "class"=>"Button"}, {"id"=>"login_button_slow", "enabled"=>true, "contentDescription"=>nil, "text"=>"Login (slow)", "qualified_class"=>"android.widget.Button", "frame"=>{"y"=>322, "height"=>73, "width"=>143, "x"=>234}, "description"=>"android.widget.Button@40585390", "class"=>"Button"}]

Page 7: Calabash automated test

RUBY

DEFINE THE CUCUMBER SCENARIO

▸ calabash_steps.rbYou’ll find more than 2 ruby file first one is :

This is class for parsing cucumber .feature files into ruby action

ex. require 'calabash-android/calabash_steps'

# Given I am on the Login PageGiven(/^I am on the Login Page$/) do page(LoginPage).on_login_pageend

# Then I touch "countrycode text"Then(/^I touch ("countrycode text")$/) do page(LoginPage).touch_country_codeend

Page 8: Calabash automated test

RUBY

DEFINE THE CUCUMBER SCENARIO

▸ <feature_name>page.rbThe second one is :

This is class is action for all test process with Calabash ruby API more detail on :

ex.require 'calabash-android/abase'

class LoginPage < Calabash::ABase

def trait"* text:'Login Page'"

end

@@editTextSearchCountryCode = "* id:'search_et'"

def touch_search_texttouch(@@editTextSearchCountryCode)

end

def insert_phone_numberenter_text(@@phoneNumber, @@phoneNumberToTest)

end

https://github.com/calabash/calabash-ios/wiki/Calabash-iOS-Ruby-API

Page 9: Calabash automated test

TEXT

DEFINE THE CUCUMBER SCENARIOrequire 'calabash-android/abase'

class LoginPage < Calabash::ABase

def trait"* text:'Login Page'"

end

@@editTextSearchCountryCode = "* id:’search_et'"@@phoneNumber = "* marked:'Input your Mobile Number’"@@phoneNumberToTest = 81615468105

def touch_search_texttouch(@@editTextSearchCountryCode)

end

def insert_phone_numberenter_text(@@phoneNumber, @@phoneNumberToTest)

end

<— this where the id from query used for}

Page 10: Calabash automated test

JENKINS PROCFILE

JENKINS PROCFILE PROCEDURE▸ run_android_featureThis config file contain all step to running the feature test on jenkins

PARAMS="-p android"

while getopts ":rd:" OPTION; do case $OPTION in

r) PARAMS=$PARAMS" --format json -o cucumber.json" ;; d) PARAMS=$PARAMS" ADB_DEVICE_ARG=$OPTARG"

;; [?]) echo "Usage: $0 [-r] [-d DEVICE_ID].\n -r: should create reports.\n DEVICE_ID: where to run tests." exit 1;; esacdone

# clear old filesrm -rf test_servers# resign apkbundle exec calabash-android build "/build/outputs/apk/app-debug.apk"# run testsbundle exec calabash-android run "/build/outputs/apk/app-debug.apk"

Page 11: Calabash automated test

SO ALL YOU NEED ONLY …▸ <feature_name>.feature on /features

▸ calabash_steps.rb on /features/step_definitions

▸ <feature_name>Page.rb on /features/support/<feature_name>

▸ And most importent file for running all test at Jenkins is run_android_feature

Page 12: Calabash automated test

GIT

HOW TO RUN YOUR TEST ON JENKINS?▸ All you need is just merge your feature branch to

branch calabash-test and wait for the test is pass or failure

▸ For more detail if failure or success you can log in to jenkins page and see the report

Page 13: Calabash automated test

JENKINS

CUCUMBER TEST RESULT

ths is example of report on jenkins for testing scenario

Page 14: Calabash automated test

THAT’S IT AND THANK YOU!