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:
- Feature: Create and delete new note
- Scenario: I should be able to create a note
- Then I press the menu key
- And I wait for "Add note" to appear
- Then I touch the "Add note" text
- And I enter "Note to be saved " into input field number 1
- Then I press the enter button
- Then I press the menu key
- And I wait for "Save" to appear
- Then I touch the "Save" text
- And I wait for "Not to be saved" to appear
- Scenario: I should be able to create and delete a note
- Then I press the menu key
- And I wait for "Add note" to appear
- Then I touch the "Add note" text
- And I enter "Not to be deleted" into input field number 1
- Then I press the enter button
- Then I press the menu key
- And I wait for "Save" to appear
- Then I touch the "Save" text
- And I wait for "Not to be deleted" to appear
- Then I touch the "The note I will delete" text
- And I wait for "Not to be deleted" to appear
- Then I press the menu key
- And I wait for "Delete" to appear
- Then I touch the "Delete" text
- 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.
0 Comments