Writing & Executing a Simple Calabash-Android Test

You write and execute your tests with Feature files, which are made up of a Feature, Scenario, and Steps (which includes assertions).

Feature

The only requirement is “Feature” followed by the description of your feature you will test.  Including the test purpose, the tester role, and test expectations are optional but you should use them for best practices.

Scenario 

Scenarios take the feature and translate it to a real world scenario.  A scenario contain steps to test the functionality of an app.  Assertions are in place to ensure your app is behaving properly and as expected.  One feature file can contain multiple scenarios.

Steps

The commands you want your script to execute. Then Assertions, expectations used to validate the responses in your tests

 

 

 Script example above.

 

Combine predefined calabash steps with queried objects in the app to write your test case. Save in the feature folder generated earlier and add the extension '.feature'

 

Begin writing your test case. It might resemble what is presented below, understand how to query to find objects and use Calabash predefined steps to interact with them:

 

  1. Feature: Create and delete new note
  2.  
  3.   Scenario: I should be able to create a note
  4.  
  5.     Then I press the menu key
  6.     And I wait for "Add note" to appear
  7.     Then I touch the "Add note" text
  8.     And I enter "Note to be saved " into input field number 1
  9.     Then I press the enter button
  10.     Then I press the menu key
  11.     And I wait for "Save" to appear
  12.     Then I touch the "Save" text
  13.     And I wait for "Not to be saved" to appear
  14.   
  15.  
  16.   Scenario: I should be able to create and delete a note
  17.  
  18.     Then I press the menu key
  19.     And I wait for "Add note" to appear
  20.     Then I touch the "Add note" text
  21.     And I enter "Not to be deleted" into input field number 1
  22.     Then I press the enter button
  23.     Then I press the menu key
  24.     And I wait for "Save" to appear
  25.     Then I touch the "Save" text
  26.     And I wait for "Not to be deleted" to appear
  27.     Then I touch the "The note I will delete" text
  28.     And I wait for "Not to be deleted" to appear
  29.     Then I press the menu key
  30.     And I wait for "Delete" to appear
  31.     Then I touch the "Delete" text   
  32.     Then I should not see "Not to be deleted"    

 

Run test to ensure it passes 

Run the following commands to execute your test case.  

$ calabash-android run <apk file> features\*.feature

  

 You should have all steps show up green, meaning all steps passed. 

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk