Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Commit 1835c06

Browse files
committed
Add calabash tests.
1 parent dec0d07 commit 1835c06

File tree

7 files changed

+141
-20
lines changed

7 files changed

+141
-20
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@add_contact
2+
Feature: Create a new contact in the contacts list
3+
In order to interact with a new contact
4+
As I user
5+
I want to add a new contact in my contacts list
6+
7+
@s1 @add_action
8+
Scenario: User can add a new contact in the contacts list
9+
Given I see the contacts list screen
10+
When I press on "Add" button
11+
Then The screen "Edit Contact Details" appears
12+
And I enter "Jon" in the "first name" textfield
13+
And I enter "Snow" in the "last name" textfield
14+
When I press on "Done" button
15+
Then I see the "Jon Snow" contact in the contact list
16+
17+

calabash/features/my_first.feature

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@remove_contact
2+
Feature: Remove an existing contact from the contacts list
3+
In order to get rid of annoying contacts
4+
As I user
5+
I want to remove an existing contact from my contacts list
6+
7+
@s1 @remove_action
8+
Scenario: User can remove an existing contact from the contacts list
9+
Given I see the contacts list screen
10+
Given I see at least one contact in the list
11+
When I press on "Edit" button
12+
And I remove the first contact
13+
Then Contacts list is empty
14+
15+

calabash/features/step_definitions/my_first_steps.rb

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
require 'calabash-cucumber/calabash_steps'
2+
3+
############
4+
# Steps
5+
############
6+
7+
Given(/^I see the contacts list screen$/) do
8+
step "The screen \"Contacts List\" appears"
9+
end
10+
11+
When(/^I press on "([^"]*)" button$/) do |arg1|
12+
if arg1 == "Back"
13+
step "I go back"
14+
else
15+
step "I touch the \"#{arg1}\" button"
16+
end
17+
end
18+
19+
Then(/^The screen "([^"]*)" appears$/) do |screen|
20+
case screen
21+
when "Edit Contact Details"
22+
wait_for { not query("UITableView accessibilityIdentifier:'com.vc.contactsEdit'").empty? }
23+
when "Contacts List"
24+
wait_for { not query("UITableView accessibilityIdentifier:'com.vc.contactsList'").empty? }
25+
when "Contact Details"
26+
wait_for { not query("UIView accessibilityIdentifier:'com.vc.contactDetails'").empty? }
27+
end
28+
end
29+
30+
Then(/^I enter "([^"]*)" in the "([^"]*)" textfield$/) do |arg1, text_field_name|
31+
32+
text_field_id = nil
33+
case text_field_name
34+
when "first name"
35+
text_field_id = "com.textfield.firstName"
36+
when "last name"
37+
text_field_id = "com.textfield.lastName"
38+
end
39+
40+
#step "I clear \"#{text_field_id}\""
41+
clear_text("textField marked: '#{text_field_id}'")
42+
step "I fill in \"#{text_field_id}\" with \"#{arg1}\""
43+
end
44+
45+
Then(/^I see the "([^"]*)" contact in the contact list$/) do |arg1|
46+
step "I should see \"#{arg1}\""
47+
expect(query("UITableViewCell accessibilityIdentifier:'com.cell.contactsList'").empty?).to be false
48+
end
49+
50+
Given(/^I see at least one contact in the list$/) do
51+
step "I press on \"Add\" button"
52+
step "I enter \"Jon\" in the \"first name\" textfield"
53+
step "I enter \"Snow\" in the \"last name\" textfield"
54+
step "I press on \"Done\" button"
55+
expect(query("tableView", numberOfRowsInSection:0)[0]).to eq(1)
56+
end
57+
58+
When(/^I press on first contact$/) do
59+
step "I touch \"com.cell.contactsList\""
60+
end
61+
62+
Then(/^I see the "([^"]*)" contact in the contact details$/) do |arg1|
63+
step "I should see \"#{arg1}\""
64+
expect(query("UILabel accessibilityIdentifier:'com.label.contactDetails'").empty?).to be false
65+
end
66+
67+
When(/^I remove the first contact$/) do
68+
touch("tableViewCell index:0 descendant tableViewCellEditControl")
69+
step "I touch the \"Delete\" button"
70+
end
71+
72+
Then(/^Contacts list is empty$/) do
73+
expect(query("tableView", numberOfRowsInSection:0)[0]).to eq(0)
74+
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@update_contact
2+
Feature: Update an existing contact in the contacts list
3+
In order to keep all my contacts up-to-date
4+
As I user
5+
I want to update an existing contact in my contacts list
6+
7+
@s1 @update_action
8+
Scenario: User can update an existing contact in the contacts list
9+
Given I see the contacts list screen
10+
Given I see at least one contact in the list
11+
When I press on first contact
12+
Then The screen "Contact Details" appears
13+
When I press on "Edit" button
14+
Then The screen "Edit Contact Details" appears
15+
And I enter "Robb" in the "first name" textfield
16+
And I enter "Stark" in the "last name" textfield
17+
When I press on "Done" button
18+
Then The screen "Contact Details" appears
19+
And I see the "Robb Stark" contact in the contact details
20+
When I press on "Back" button
21+
Then I see the "Robb Stark" contact in the contact list
22+
23+

fastlane/Fastfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ platform :ios do
66
before_all do
77
end
88

9-
lane :build do
9+
lane :build do |params|
1010
xcodebuild(
11-
scheme: "Contacts",
11+
scheme: params[:scheme],
1212
build: true,
1313
sdk: "iphonesimulator",
1414
derivedDataPath: "build",
@@ -19,12 +19,20 @@ platform :ios do
1919
end
2020

2121
lane :test_appium do
22-
build
22+
build(
23+
scheme: "Contacts"
24+
)
25+
2326
sh "cd ../appium && cucumber"
2427
end
25-
28+
2629
lane :test_calabash do
30+
build(
31+
scheme: "Contacts-cal"
32+
)
2733

34+
sh "export APP_BUNDLE_PATH=\"../Build/Products/Debug-iphonesimulator/Contacts-cal.app\""
35+
sh "cd ../calabash && cucumber"
2836
end
2937

3038
lane :test_ui_automation do

0 commit comments

Comments
 (0)