ego meetup - Сalabash in mobile automated testing

29
eGo Creative Media Solutions

Upload: ego-creative-media-solutions

Post on 13-Jan-2015

287 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: eGo meetup - Сalabash in mobile automated testing

eGo Creative Media Solutions

Page 2: eGo meetup - Сalabash in mobile automated testing

Acceptance testing

Page 3: eGo meetup - Сalabash in mobile automated testing

Behavior-driven development (BDD)

BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology

Page 4: eGo meetup - Сalabash in mobile automated testing

What is Calabash?

Calabash provides a bridge that allows Cucumber tests to run and validate on iOS and Android

Page 5: eGo meetup - Сalabash in mobile automated testing

Calabash

● Cucumber - framework that performs tests

● Calabash – bridge to device

● Gherkin - syntax

Cucumber + Calabash & Ruby + Gherkin

Page 6: eGo meetup - Сalabash in mobile automated testing

Calabash’s Client-Server Model

Calabash has a Client-Server model in which the server

portion is a lightweight web server that runs on the device

and listens for a client to connect and initiate the tests.

It then communicates via JSON over HTTP

Page 7: eGo meetup - Сalabash in mobile automated testing

Calabash in Android

Page 8: eGo meetup - Сalabash in mobile automated testing

Calabash in iOS

Page 9: eGo meetup - Сalabash in mobile automated testing

Calabash.app

Page 10: eGo meetup - Сalabash in mobile automated testing

Calabash-iOS setup

calabash-ios setup

calabash-ios gen

Page 11: eGo meetup - Сalabash in mobile automated testing

Calabash-iOS setup

Drag calabash.framework from Finder into your project's Frameworks folder in Xcode.

Make sure thata. Copy items into destination group's folder (if needed) is checked andb. only your "-cal " target is checked in Add to targets.

You must also link you -cal target with CFNetwork.framework (unless your production target is already linking

with CFNetwork). To do this click on your -cal target in XCode. Click on Build Phases, expand Link Binary

with Libraries, click + to add CFNetwork.framework.

o Click on your project and select your new "-cal" target.o Select "Build Settings".o Ensure that "All" and not "Basic" settings are selected in "build settings".o Find "Other Linker Flags" (you can type "other link" in the search field).o Ensure that "Other linker flags" contains: -force_load

"$(SRCROOT)/calabash.framework/calabash" -lstdc++

Page 12: eGo meetup - Сalabash in mobile automated testing

Calabash-iOS setup

Page 13: eGo meetup - Сalabash in mobile automated testing

Calabash with Xamarin

Page 14: eGo meetup - Сalabash in mobile automated testing

Calabash iOS/Android gen

Page 15: eGo meetup - Сalabash in mobile automated testing

Config

Page 16: eGo meetup - Сalabash in mobile automated testing

cucumber.yml

# config/cucumber.yml

##YAML Template

android: PLATFORM=android -r features/support -r features/android/support -r features/android/helpers -r features/step_definitions -r features/android/pages

ios: PLATFORM=ios SDK_VERSION=7.0 -r features/support -r features/ios/support -r features/ios/helpers -r features/step_definitions -r features/ios/pages

iPhone: DEVICE=iphoneiPad: DEVICE=ipad

Page 17: eGo meetup - Сalabash in mobile automated testing

Test anatomy

Page 18: eGo meetup - Сalabash in mobile automated testing

Test practice

● Write the feature – As described in the overview, the developer and a subject matter expert work together

to write the Calabash feature. They create a .feature file that describes how the scenarios should work.

● Run the feature – Next, the developer runs the feature that was created. It will fail because the steps have

not yet been defined. However, Cucumber will help us out by providing some code snippets that we can use

to create the step definitions.

● Create the Step Definitions – Using the snippets that Cucumber provided in step #2, we create a Ruby

source code file, and paste the snippet output into it.

● Explore the Application using the Calabash Console – Not strictly necessary, this step involves starting

up an instance of the Calabash console. The Calabash console is a command line utility that allows us to

issue commands to the Calabash test server communicating with our app. We can use this to discover the

Calabash queries necessary to interact with the UI object in the application.

Page 19: eGo meetup - Сalabash in mobile automated testing

Test practice

● Update Step Definitions – Once we have figured out the Calabash queries for locating and manipulating

the UI object, we can use these - along with the Calabash API - to implement the step definitions.

● Run the Feature – When the step definitions are finished, we can run the features. If this is a brownfield

application, the functionality has already been coded and the tests should all pass. If this is a greenfield

project, the tests will not pass as there is no application code – we will move on to step #7 below.

● Implement the Feature in the Application – This step is only necessary in a greenfield project. The

developer will shift attention to the application and write the code to implement the desired functionality, and

make the test pass.

● Repeat – Once the feature is implemented with a passing test, it is done. Time to move on and implement

the next bit of functionality in the application.

Page 20: eGo meetup - Сalabash in mobile automated testing

First feature example

credit_card_validation.feature

Feature: Credit card validation. Credit card numbers must be exactly 16 digits.

Scenario: Credit card number is to short Given I use the native keyboard to enter "123456" into text field number 1 And I touch the "Validate" button Then I see the text "Credit card number is to short."

Page 21: eGo meetup - Сalabash in mobile automated testing

First feature execution

Console Log$ cucumberFeature: Credit card validation. Credit card numbers must be exactly 16 digits.

Sceanario: Credit Card is too short # features/credit_card_validation.feature:4

Given I use the native keyboard to enter "123456" into text field number 1 # calabash-cucumber-0.9.162/features/step_definitions/calabash_steps.rb:140 And I touch the "Validate" button # calabash-cucumber-0.9.162/features/step_definitions/calabash_steps.rb:31 Then I see the text "Credit card number is to short." # calabash-cucumber-0.9.162/features/step_definitions/calabash_steps.rb:3731 scenario (1 passed)3 steps (3 passed)0m18.035s

Page 22: eGo meetup - Сalabash in mobile automated testing

Second feature

Implementing the Second Scenario

Scenario: Credit card number is to long Given I try to validate a credit card number that is 17 characters long Then I should see the error message "Credit card number is to long."

Page 23: eGo meetup - Сalabash in mobile automated testing

First rough going

Page 24: eGo meetup - Сalabash in mobile automated testing

Step definitions

Page 25: eGo meetup - Сalabash in mobile automated testing

Calabash Ruby API

Calabash has a client-server architecture. The Calabash Ruby API is the client side which communicates over HTTP with the server that is embedded in your app via the Calabash component.

Page 26: eGo meetup - Сalabash in mobile automated testing

Calabash query

Page 27: eGo meetup - Сalabash in mobile automated testing

Uploading and Executing Tests in Test Cloud

Page 28: eGo meetup - Сalabash in mobile automated testing

Resources

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

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

http://docs.xamarin.com/guides/testcloud/calabash/

http://docs.xamarin.com/guides/testcloud/calabash/calabash-predefined-steps/

http://calaba.sh/

http://cukes.info/

https://github.com/xamarin/mobile-samples

Page 29: eGo meetup - Сalabash in mobile automated testing

Thank You