SlideShare a Scribd company logo
iOS Automation
XCUITest + Gherkin
• Technical Lead iOS Engineer @ PropertyGuru
• Agile, Xtreme Programming
• Tests
• Calabash-iOS ----> XCUITest
• Demo [https://github.com/depoon/WeatherAppDemo]
Agenda
1. Introduction XCUITest
2. Building a simple Test Suite
3. Gherkin for XCUITest
XCUITest
• Introduced in Xcode 7 in 2015
• xUnit Test Cases (XCTestCase)
• UITest targets cant see production codes
• Builds and tests are all executed using XCode
(ObjC/Swift)
• Record functionality
1. Introduction (iOS Automation Tools, XCUITest)
XCUITest - Recording
1. Introduction (iOS Automation Tools, XCUITest)
[Source] http://blog.xebia.com/automated-ui-testing-with-react-native-on-ios/
XCUITest - XCUIElement
1. Introduction (iOS Automation Tools, XCUITest)
XCUIElement
//Elements are objects encapsulating the information needed to dynamically locate a user interface.element in an
application. Elements are described in terms of queries [Apple Documentation - XCTest]
let app = XCUIApplication() //Object that queries views on the app
app.staticTexts //returns XCUIElementQuery “collection” representing “UILabels”
app.buttons //returns XCUIElementQuery “collection” of representing “UIButtons”
app.tables //returns XCUIElementQuery “collection” of representing “UITables”
app.tables.staticTexts
//returns XCUIElementQuery “collection” representing “UILabels” which has superviews of type “UITable”
app.staticTexts[“Hello World”]
//returns a label element with accessibilityIdentifier or text value “Hello World”
app.tables[“myTable”]
//returns a table element with accessibilityIdentifier “myTable”
1. Introduction (iOS Automation Tools, XCUITest)
groups
disclosureTrian
gles
tabGroups sliders images menus
windows popUpButtons toolbars pageIndicators icons menuItems
sheets comboBoxes statusBars
progressIndicat
ors
searchFields menuBars
drawers menuButtons tables
activityIndicator
s
scrollViews menuBarItems
alerts toolbarButtons tableRows
segmentedCon
trols
scrollBars maps
dialogs popovers tableColumns pickers staticTexts webViews
buttons keyboards outlines pickerWheels textFields steppers
radioButtons keys outlineRows switches
secureTextFiel
ds
cells
radioGroups navigationBars browsers toggles datePickers layoutAreas
checkBoxes tabBars collectionViews links textViews otherElements
app.otherElements //returns [ elements ] of UIView
XCUITest - XCUIElement
XCUITest - Interactions
1. Introduction (iOS Automation Tools, XCUITest)
let app = XCUIApplication() //Object that queries views on the app
app.staticTexts[“Hello World”].exists //returns true if element exists
app.buttons[“Save”].tap() //taps the “Save” button
app.tables[“myTable”].swipeUp() //swipes up the table
app.textFields[“myField”].typeText(“John Doe”) //types value in textField
Other interactions: pinchWithScale, pressForDuration, doubleTap()
XCTAssertTrue(app.staticTexts[“Hello World”].exists) //Throws exception if label does not exists
Requirements
2. Building a simple test suite
Create a Weather App
1. Given I am at the City Search Screen
When I search for a valid city (eg “London”)
Then I should see a weather details page of that city
2. Given I am at the City Search Screen
When I search for an invalid city (eg “NotACity”)
Then I should see an error message
Here’s what we built
2. Building a simple test suite
Creating a UITest Target
2. Building a simple test suite
Recording - Valid City
2. Building a simple test suite
Recording - Invalid City
2. Building a simple test suite
Generated Code - Valid City
2. Building a simple test suite
func testUserAbleToSearchForValidCity() {
let app = app2
app.searchFields["Search a city"].tap()
app.searchFields["Search a city"]
let app2 = app
app2.buttons["Search"].tap()
app.searchFields["Search a city"]
let tablesQuery = app2.tables
tablesQuery.staticTexts["London"].tap()
tablesQuery.staticTexts["53"].tap()
tablesQuery.staticTexts["Partly Cloudy"].tap()
}
Generated Code - Invalid City
2. Building a simple test suite
func testUserSeesErrorMessageForInvalidCity() {
let app = XCUIApplciation()
app.searchFields["Search a city"].tap()
app.searchFields["Search a city"]
app.buttons["Search"].tap()
app.searchFields["Search a city"]
let errorAlert = app.alerts["Error"]
errorAlert.staticTexts["Error"].tap()
errorAlert.staticTexts[
"Unable to find any matching weather location to the query submitted!”
].tap()
errorAlert.collectionViews["OK"].tap()
}
2. Building a simple test suite
func testUserAbleToSearchForValidCity() {
let app = XCUIApplication()
let searchField = app.searchFields["Search a city"]
searchField.tap()
searchField.typeText("London")
app.buttons["Search"].tap()
self.userWaitsToSeeText("London")
self.userWaitsToSeeText("53")
self.userWaitsToSeeText("Partly Cloudy”)
self.waitForExpectationsWithTimeout(5, handler: nil)
}
private func userWaitsToSeeText(text: String){
self.expectationForPredicate(
NSPredicate(format: "exists == 1"),
evaluatedWithObject: XCUIApplication().tables.staticTexts[text],
handler: nil
)
// XCUIApplication().tables.staticTexts[text].exists <— boolean
}
Refactored Code
2. Building a simple test suite
func testUserSeesErrorMessageForInvalidCity() {
let app = XCUIApplication()
let searchField = app.searchFields["Search a city”]
searchField.tap()
searchField.typeText("NotACity")
app.buttons["Search"].tap()
self.userWaitsToSeeText("Error")
self.userWaitsToSeeText(
"Unable to find any matching weather location to the query submitted!"
)
self.waitForExpectationsWithTimeout(5, handler: nil)
self.userTapsOnAlertButton("OK")
}
private func userTapsOnAlertButton(buttonTitle: String){
XCUIApplication().buttons[buttonTitle].tap()
}
Refactored Code
2. Building a simple test suite
Scheme Management
2. Building a simple test suite
Scheme Management
Gherkin
3. Use Gherkins
(User Registration)
Given I am at the user registration page
When I enter invalid email address
And I tap “Register“
Then I should see “Invalid Email Address”
Gherkin - Example 1
3. Use Gherkins
(Shopping with existing Items in shopping cart)
Given I have 1 Wallet and 1 Belt in my shopping cart
And I am at the Shopping Item Details Page for a Bag
When I select quantity as “1”
And I tap on “Add to Shopping Cart”
Then I should be at Shopping Cart Screen
And I should see “3” total items in my shopping cart
Gherkin - Example 2
3. Use Gherkins
2. Building a simple test suite
Given I am at Weather Search Form Page
When I enter city search for “London”
Then I should be at Weather Details Page
And I wait to see “London”
And I wait to see “53”
Gherkin - Our Acceptance Tests
2. Building a simple test suite
Given I am at Weather Search Form Page
When I enter city search for “NotACity”
Then I wait to see “Error”
And I wait to see “Unable to …”
And I tap on alert button “OK”
Gherkin - Our Acceptance Tests
3. Use Gherkins
• Language used in Behavioural Driven Development (BDD) to
specify software requirements with examples
• Executable, facilitate collaboration with non developers
• Lets add Gherkin to our project in Xcode
https://github.com/net-a-porter-mobile/XCTest-Gherkin
pod 'XCTest-Gherkin'
Gherkin
3. Use Gherkins[Source] https://github.com/net-a-porter-mobile/XCTest-Gherkin
Gherkin
3. Use Gherkins
Given I am at Weather Search Form Page
When I enter city search for “London”
Then I should be at Weather Details Page
And I wait to see “London”
And I wait to see “53”
step("I (am|should be) at Weather Search Form Page”) {
let weatherSearchPage = WeatherSearchPage(self.test)
}
struct WeatherSearchPage{
init(testCase: XCTestCase){
testCase.expectationForPredicate(
NSPredicate(format: “exists == 1”),
evaluatedWithObject: XCUIApplication().otherElements[“WeatherSearchPage”],
handler: nil
)
testCase.waitForExpectationsWithTimeout(5, handler: nil)
}
}
3. Use Gherkins
Given I am at Weather Search Form Screen
When I enter city search for “London”
Then I should be at Weather Details Page
And I wait to see “London”
And I wait to see “53”
step("I enter city search for ”(.*?)””) { (matches: [String]) in
let weatherSearchPage = WeatherSearchPage(testCase: self.test)
weatherSearchPage.userSearchForCity(matches.first!)
}
struct WeatherSearchPage{
func userSearchForCity(city: String){
let app = XCUIApplication()
let searchField = app.searchFields[“Search a city”]
searchField.tap()
searchField.typeText(city)
app.buttons[“Search”].tap()
}
}
3. Use Gherkins
Given I am at Weather Search Form Page
When I enter city search for “London”
Then I should be at Weather Details Page
And I wait to see “London”
And I wait to see “53”
step("I (am|should be) at Weather Details Page”) {
WeatherDetailsPage(testCase: self.test)
}
struct WeatherDetailsPage{
init(testCase: XCTestCase){
testCase.expectationForPredicate(
NSPredicate(format: “exists == 1”),
evaluatedWithObject: XCUIApplication().otherElements[“Weather Forecast”],
handler: nil
)
testCase.waitForExpectationsWithTimeout(5, handler: nil)
}
}
3. Use Gherkins
Given I am at Weather Search Form Page
When I enter city search for “London”
Then I should be at Weather Details Page
And I wait to see “London”
And I wait to see “53”
step("I wait to see ”(.*?)””) { (matches: [String]) in
self.test.expectationForPredicate(
NSPredicate(format: “exists == 1”),
evaluatedWithObject: XCUIApplication().staticTexts[matches.first!],
handler: nil
)
self.test.waitForExpectationsWithTimeout(5, handler: nil)
}
3. Use Gherkins
Given I am at Weather Search Form Page
When I enter city search for “NotACity”
Then I wait to see “Error”
Then I wait to see “Unable to …”
Then I tap on alert button “OK”
step("I tap on alert button ”(.*?)””) {
XCUIApplication().buttons[matches.first!].tap()
}
3. Use Gherkins
Using an additional pod to simply statements -
https://github.com/joemasilotti/JAMTestHelper
Gherkin
3. Use Gherkins
Using an additional pod to simply statements -
https://github.com/joemasilotti/JAMTestHelper
Gherkin
3. Use Gherkins
Gherkin
3. Use Gherkins
Gherkin
3. Use Gherkins
Gherkin
Gherkin
3. Use Gherkins
Gherkin
3. Use Gherkins
Gherkin - Using Feature File
3. Use Gherkins
Why should I use Gherkin with
XCUITest?
3. Use Gherkins
• Acceptance Test Driven Development
• Cross platform testing is still possible without need for 3rd
party tools
• Objective C + Swift
Questions?
kenneth@propertyguru.com.sg
de_poon@hotmail.com

More Related Content

What's hot

Angular 6 - The Complete Guide
Angular 6 - The Complete GuideAngular 6 - The Complete Guide
Angular 6 - The Complete Guide
Sam Dias
 
Unit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introUnit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma intro
Maurice De Beijer [MVP]
 
Convert Postman APIs collections to JMeter
Convert Postman APIs collections to JMeterConvert Postman APIs collections to JMeter
Convert Postman APIs collections to JMeter
Basant Dewangan
 
RESTful API Testing using Postman, Newman, and Jenkins
RESTful API Testing using Postman, Newman, and JenkinsRESTful API Testing using Postman, Newman, and Jenkins
RESTful API Testing using Postman, Newman, and Jenkins
QASymphony
 
webpack 101 slides
webpack 101 slideswebpack 101 slides
webpack 101 slides
mattysmith
 
Jetpack Compose a nova forma de implementar UI no Android
Jetpack Compose a nova forma de implementar UI no AndroidJetpack Compose a nova forma de implementar UI no Android
Jetpack Compose a nova forma de implementar UI no Android
Nelson Glauber Leal
 
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...
Postman
 
Express JS
Express JSExpress JS
Express JS
Alok Guha
 
安全なPHPアプリケーションの作り方2016
安全なPHPアプリケーションの作り方2016安全なPHPアプリケーションの作り方2016
安全なPHPアプリケーションの作り方2016
Hiroshi Tokumaru
 
Java basic
Java basicJava basic
Java basic
Arati Gadgil
 
Belajar Postman test runner
Belajar Postman test runnerBelajar Postman test runner
Belajar Postman test runner
Fachrul Choliluddin
 
Api Testing
Api TestingApi Testing
Api Testing
Vishwanath KC
 
Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017
Roman Elizarov
 
Test automation of ap is using postman
Test automation of ap is using postmanTest automation of ap is using postman
Test automation of ap is using postman
BugRaptors
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaSanjeev Tripathi
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
Coding Academy
 
Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins
Udaya Kumar
 
Nodejs functions & modules
Nodejs functions & modulesNodejs functions & modules
Nodejs functions & modules
monikadeshmane
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test Automaion
Knoldus Inc.
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
Alessandro Giorgetti
 

What's hot (20)

Angular 6 - The Complete Guide
Angular 6 - The Complete GuideAngular 6 - The Complete Guide
Angular 6 - The Complete Guide
 
Unit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introUnit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma intro
 
Convert Postman APIs collections to JMeter
Convert Postman APIs collections to JMeterConvert Postman APIs collections to JMeter
Convert Postman APIs collections to JMeter
 
RESTful API Testing using Postman, Newman, and Jenkins
RESTful API Testing using Postman, Newman, and JenkinsRESTful API Testing using Postman, Newman, and Jenkins
RESTful API Testing using Postman, Newman, and Jenkins
 
webpack 101 slides
webpack 101 slideswebpack 101 slides
webpack 101 slides
 
Jetpack Compose a nova forma de implementar UI no Android
Jetpack Compose a nova forma de implementar UI no AndroidJetpack Compose a nova forma de implementar UI no Android
Jetpack Compose a nova forma de implementar UI no Android
 
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...
 
Express JS
Express JSExpress JS
Express JS
 
安全なPHPアプリケーションの作り方2016
安全なPHPアプリケーションの作り方2016安全なPHPアプリケーションの作り方2016
安全なPHPアプリケーションの作り方2016
 
Java basic
Java basicJava basic
Java basic
 
Belajar Postman test runner
Belajar Postman test runnerBelajar Postman test runner
Belajar Postman test runner
 
Api Testing
Api TestingApi Testing
Api Testing
 
Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017
 
Test automation of ap is using postman
Test automation of ap is using postmanTest automation of ap is using postman
Test automation of ap is using postman
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
 
Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins
 
Nodejs functions & modules
Nodejs functions & modulesNodejs functions & modules
Nodejs functions & modules
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test Automaion
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 

Similar to iOS Automation: XCUITest + Gherkin

Testing view controllers with Quick and Nimble
Testing view controllers with Quick and NimbleTesting view controllers with Quick and Nimble
Testing view controllers with Quick and Nimble
Marcio Klepacz
 
Android Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveAndroid Wear: A Developer's Perspective
Android Wear: A Developer's Perspective
Vin Lim
 
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web TestingBDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
John Ferguson Smart Limited
 
iOS and Android apps automation
iOS and Android apps automationiOS and Android apps automation
iOS and Android apps automation
Sridhar Ramakrishnan
 
Common mistakes in android development
Common mistakes in android developmentCommon mistakes in android development
Common mistakes in android development
Hoang Nguyen Huu
 
Mobile Worshop Lab guide
Mobile Worshop Lab guideMobile Worshop Lab guide
Mobile Worshop Lab guide
Man Chan
 
Unit3.pptx
Unit3.pptxUnit3.pptx
Unit3.pptx
AnamikaRai59
 
Puppeteer - A web scraping & UI Testing Tool
Puppeteer - A web scraping & UI Testing ToolPuppeteer - A web scraping & UI Testing Tool
Puppeteer - A web scraping & UI Testing Tool
Miki Lombardi
 
How to develop automated tests
How to develop automated testsHow to develop automated tests
How to develop automated tests
Odoo
 
Building a DRYer Android App with Kotlin
Building a DRYer Android App with KotlinBuilding a DRYer Android App with Kotlin
Building a DRYer Android App with Kotlin
Boonya Kitpitak
 
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
mharkus
 
Testing and Building Android
Testing and Building AndroidTesting and Building Android
Testing and Building AndroidDroidcon Berlin
 
20150812 4시간만에 따라해보는 windows 10 앱 개발
20150812  4시간만에 따라해보는 windows 10 앱 개발20150812  4시간만에 따라해보는 windows 10 앱 개발
20150812 4시간만에 따라해보는 windows 10 앱 개발
영욱 김
 
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptxLecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
NgLQun
 
SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFest
tomdale
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
Containers & Dependency in Ember.js
Containers & Dependency in Ember.jsContainers & Dependency in Ember.js
Containers & Dependency in Ember.js
Matthew Beale
 
Android Building, Testing and reversing
Android Building, Testing and reversingAndroid Building, Testing and reversing
Android Building, Testing and reversing
Enrique López Mañas
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
Ho Chi Minh City Software Testing Club
 

Similar to iOS Automation: XCUITest + Gherkin (20)

Testing view controllers with Quick and Nimble
Testing view controllers with Quick and NimbleTesting view controllers with Quick and Nimble
Testing view controllers with Quick and Nimble
 
Android Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveAndroid Wear: A Developer's Perspective
Android Wear: A Developer's Perspective
 
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web TestingBDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
 
iOS and Android apps automation
iOS and Android apps automationiOS and Android apps automation
iOS and Android apps automation
 
Winrunner
WinrunnerWinrunner
Winrunner
 
Common mistakes in android development
Common mistakes in android developmentCommon mistakes in android development
Common mistakes in android development
 
Mobile Worshop Lab guide
Mobile Worshop Lab guideMobile Worshop Lab guide
Mobile Worshop Lab guide
 
Unit3.pptx
Unit3.pptxUnit3.pptx
Unit3.pptx
 
Puppeteer - A web scraping & UI Testing Tool
Puppeteer - A web scraping & UI Testing ToolPuppeteer - A web scraping & UI Testing Tool
Puppeteer - A web scraping & UI Testing Tool
 
How to develop automated tests
How to develop automated testsHow to develop automated tests
How to develop automated tests
 
Building a DRYer Android App with Kotlin
Building a DRYer Android App with KotlinBuilding a DRYer Android App with Kotlin
Building a DRYer Android App with Kotlin
 
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
 
Testing and Building Android
Testing and Building AndroidTesting and Building Android
Testing and Building Android
 
20150812 4시간만에 따라해보는 windows 10 앱 개발
20150812  4시간만에 따라해보는 windows 10 앱 개발20150812  4시간만에 따라해보는 windows 10 앱 개발
20150812 4시간만에 따라해보는 windows 10 앱 개발
 
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptxLecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
 
SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFest
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Containers & Dependency in Ember.js
Containers & Dependency in Ember.jsContainers & Dependency in Ember.js
Containers & Dependency in Ember.js
 
Android Building, Testing and reversing
Android Building, Testing and reversingAndroid Building, Testing and reversing
Android Building, Testing and reversing
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
 

More from Kenneth Poon

Mobile Development integration tests
Mobile Development integration testsMobile Development integration tests
Mobile Development integration tests
Kenneth Poon
 
Make XCUITest Great Again
Make XCUITest Great AgainMake XCUITest Great Again
Make XCUITest Great Again
Kenneth Poon
 
Mobile Testing Tips - Let's achieve fast feedback loops
Mobile Testing Tips - Let's achieve fast feedback loopsMobile Testing Tips - Let's achieve fast feedback loops
Mobile Testing Tips - Let's achieve fast feedback loops
Kenneth Poon
 
Network Interception - Write Swift codes to inspect network requests (even wi...
Network Interception - Write Swift codes to inspect network requests (even wi...Network Interception - Write Swift codes to inspect network requests (even wi...
Network Interception - Write Swift codes to inspect network requests (even wi...
Kenneth Poon
 
PropertyGuru is Hiring. iOS / Android Engineer (Bangkok, Thailand)
PropertyGuru is Hiring. iOS / Android Engineer (Bangkok, Thailand)PropertyGuru is Hiring. iOS / Android Engineer (Bangkok, Thailand)
PropertyGuru is Hiring. iOS / Android Engineer (Bangkok, Thailand)
Kenneth Poon
 
Advanced Project 1: Heart Bleed
Advanced Project 1: Heart BleedAdvanced Project 1: Heart Bleed
Advanced Project 1: Heart Bleed
Kenneth Poon
 
CNY Distribution of Oranges, Uplifting the spirit [@TPCTMC]
CNY Distribution of Oranges, Uplifting the spirit [@TPCTMC]CNY Distribution of Oranges, Uplifting the spirit [@TPCTMC]
CNY Distribution of Oranges, Uplifting the spirit [@TPCTMC]Kenneth Poon
 

More from Kenneth Poon (7)

Mobile Development integration tests
Mobile Development integration testsMobile Development integration tests
Mobile Development integration tests
 
Make XCUITest Great Again
Make XCUITest Great AgainMake XCUITest Great Again
Make XCUITest Great Again
 
Mobile Testing Tips - Let's achieve fast feedback loops
Mobile Testing Tips - Let's achieve fast feedback loopsMobile Testing Tips - Let's achieve fast feedback loops
Mobile Testing Tips - Let's achieve fast feedback loops
 
Network Interception - Write Swift codes to inspect network requests (even wi...
Network Interception - Write Swift codes to inspect network requests (even wi...Network Interception - Write Swift codes to inspect network requests (even wi...
Network Interception - Write Swift codes to inspect network requests (even wi...
 
PropertyGuru is Hiring. iOS / Android Engineer (Bangkok, Thailand)
PropertyGuru is Hiring. iOS / Android Engineer (Bangkok, Thailand)PropertyGuru is Hiring. iOS / Android Engineer (Bangkok, Thailand)
PropertyGuru is Hiring. iOS / Android Engineer (Bangkok, Thailand)
 
Advanced Project 1: Heart Bleed
Advanced Project 1: Heart BleedAdvanced Project 1: Heart Bleed
Advanced Project 1: Heart Bleed
 
CNY Distribution of Oranges, Uplifting the spirit [@TPCTMC]
CNY Distribution of Oranges, Uplifting the spirit [@TPCTMC]CNY Distribution of Oranges, Uplifting the spirit [@TPCTMC]
CNY Distribution of Oranges, Uplifting the spirit [@TPCTMC]
 

Recently uploaded

Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 

Recently uploaded (20)

Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 

iOS Automation: XCUITest + Gherkin

  • 2. • Technical Lead iOS Engineer @ PropertyGuru • Agile, Xtreme Programming • Tests • Calabash-iOS ----> XCUITest • Demo [https://github.com/depoon/WeatherAppDemo]
  • 3. Agenda 1. Introduction XCUITest 2. Building a simple Test Suite 3. Gherkin for XCUITest
  • 4. XCUITest • Introduced in Xcode 7 in 2015 • xUnit Test Cases (XCTestCase) • UITest targets cant see production codes • Builds and tests are all executed using XCode (ObjC/Swift) • Record functionality 1. Introduction (iOS Automation Tools, XCUITest)
  • 5. XCUITest - Recording 1. Introduction (iOS Automation Tools, XCUITest) [Source] http://blog.xebia.com/automated-ui-testing-with-react-native-on-ios/
  • 6. XCUITest - XCUIElement 1. Introduction (iOS Automation Tools, XCUITest) XCUIElement //Elements are objects encapsulating the information needed to dynamically locate a user interface.element in an application. Elements are described in terms of queries [Apple Documentation - XCTest] let app = XCUIApplication() //Object that queries views on the app app.staticTexts //returns XCUIElementQuery “collection” representing “UILabels” app.buttons //returns XCUIElementQuery “collection” of representing “UIButtons” app.tables //returns XCUIElementQuery “collection” of representing “UITables” app.tables.staticTexts //returns XCUIElementQuery “collection” representing “UILabels” which has superviews of type “UITable” app.staticTexts[“Hello World”] //returns a label element with accessibilityIdentifier or text value “Hello World” app.tables[“myTable”] //returns a table element with accessibilityIdentifier “myTable”
  • 7. 1. Introduction (iOS Automation Tools, XCUITest) groups disclosureTrian gles tabGroups sliders images menus windows popUpButtons toolbars pageIndicators icons menuItems sheets comboBoxes statusBars progressIndicat ors searchFields menuBars drawers menuButtons tables activityIndicator s scrollViews menuBarItems alerts toolbarButtons tableRows segmentedCon trols scrollBars maps dialogs popovers tableColumns pickers staticTexts webViews buttons keyboards outlines pickerWheels textFields steppers radioButtons keys outlineRows switches secureTextFiel ds cells radioGroups navigationBars browsers toggles datePickers layoutAreas checkBoxes tabBars collectionViews links textViews otherElements app.otherElements //returns [ elements ] of UIView XCUITest - XCUIElement
  • 8. XCUITest - Interactions 1. Introduction (iOS Automation Tools, XCUITest) let app = XCUIApplication() //Object that queries views on the app app.staticTexts[“Hello World”].exists //returns true if element exists app.buttons[“Save”].tap() //taps the “Save” button app.tables[“myTable”].swipeUp() //swipes up the table app.textFields[“myField”].typeText(“John Doe”) //types value in textField Other interactions: pinchWithScale, pressForDuration, doubleTap() XCTAssertTrue(app.staticTexts[“Hello World”].exists) //Throws exception if label does not exists
  • 9. Requirements 2. Building a simple test suite Create a Weather App 1. Given I am at the City Search Screen When I search for a valid city (eg “London”) Then I should see a weather details page of that city 2. Given I am at the City Search Screen When I search for an invalid city (eg “NotACity”) Then I should see an error message
  • 10. Here’s what we built 2. Building a simple test suite
  • 11. Creating a UITest Target 2. Building a simple test suite
  • 12. Recording - Valid City 2. Building a simple test suite
  • 13. Recording - Invalid City 2. Building a simple test suite
  • 14. Generated Code - Valid City 2. Building a simple test suite func testUserAbleToSearchForValidCity() { let app = app2 app.searchFields["Search a city"].tap() app.searchFields["Search a city"] let app2 = app app2.buttons["Search"].tap() app.searchFields["Search a city"] let tablesQuery = app2.tables tablesQuery.staticTexts["London"].tap() tablesQuery.staticTexts["53"].tap() tablesQuery.staticTexts["Partly Cloudy"].tap() }
  • 15. Generated Code - Invalid City 2. Building a simple test suite func testUserSeesErrorMessageForInvalidCity() { let app = XCUIApplciation() app.searchFields["Search a city"].tap() app.searchFields["Search a city"] app.buttons["Search"].tap() app.searchFields["Search a city"] let errorAlert = app.alerts["Error"] errorAlert.staticTexts["Error"].tap() errorAlert.staticTexts[ "Unable to find any matching weather location to the query submitted!” ].tap() errorAlert.collectionViews["OK"].tap() }
  • 16. 2. Building a simple test suite func testUserAbleToSearchForValidCity() { let app = XCUIApplication() let searchField = app.searchFields["Search a city"] searchField.tap() searchField.typeText("London") app.buttons["Search"].tap() self.userWaitsToSeeText("London") self.userWaitsToSeeText("53") self.userWaitsToSeeText("Partly Cloudy”) self.waitForExpectationsWithTimeout(5, handler: nil) } private func userWaitsToSeeText(text: String){ self.expectationForPredicate( NSPredicate(format: "exists == 1"), evaluatedWithObject: XCUIApplication().tables.staticTexts[text], handler: nil ) // XCUIApplication().tables.staticTexts[text].exists <— boolean } Refactored Code
  • 17. 2. Building a simple test suite func testUserSeesErrorMessageForInvalidCity() { let app = XCUIApplication() let searchField = app.searchFields["Search a city”] searchField.tap() searchField.typeText("NotACity") app.buttons["Search"].tap() self.userWaitsToSeeText("Error") self.userWaitsToSeeText( "Unable to find any matching weather location to the query submitted!" ) self.waitForExpectationsWithTimeout(5, handler: nil) self.userTapsOnAlertButton("OK") } private func userTapsOnAlertButton(buttonTitle: String){ XCUIApplication().buttons[buttonTitle].tap() } Refactored Code
  • 18. 2. Building a simple test suite Scheme Management
  • 19. 2. Building a simple test suite Scheme Management
  • 21. (User Registration) Given I am at the user registration page When I enter invalid email address And I tap “Register“ Then I should see “Invalid Email Address” Gherkin - Example 1 3. Use Gherkins
  • 22. (Shopping with existing Items in shopping cart) Given I have 1 Wallet and 1 Belt in my shopping cart And I am at the Shopping Item Details Page for a Bag When I select quantity as “1” And I tap on “Add to Shopping Cart” Then I should be at Shopping Cart Screen And I should see “3” total items in my shopping cart Gherkin - Example 2 3. Use Gherkins
  • 23. 2. Building a simple test suite Given I am at Weather Search Form Page When I enter city search for “London” Then I should be at Weather Details Page And I wait to see “London” And I wait to see “53” Gherkin - Our Acceptance Tests
  • 24. 2. Building a simple test suite Given I am at Weather Search Form Page When I enter city search for “NotACity” Then I wait to see “Error” And I wait to see “Unable to …” And I tap on alert button “OK” Gherkin - Our Acceptance Tests
  • 25. 3. Use Gherkins • Language used in Behavioural Driven Development (BDD) to specify software requirements with examples • Executable, facilitate collaboration with non developers • Lets add Gherkin to our project in Xcode https://github.com/net-a-porter-mobile/XCTest-Gherkin pod 'XCTest-Gherkin' Gherkin
  • 26. 3. Use Gherkins[Source] https://github.com/net-a-porter-mobile/XCTest-Gherkin Gherkin
  • 27. 3. Use Gherkins Given I am at Weather Search Form Page When I enter city search for “London” Then I should be at Weather Details Page And I wait to see “London” And I wait to see “53” step("I (am|should be) at Weather Search Form Page”) { let weatherSearchPage = WeatherSearchPage(self.test) } struct WeatherSearchPage{ init(testCase: XCTestCase){ testCase.expectationForPredicate( NSPredicate(format: “exists == 1”), evaluatedWithObject: XCUIApplication().otherElements[“WeatherSearchPage”], handler: nil ) testCase.waitForExpectationsWithTimeout(5, handler: nil) } }
  • 28. 3. Use Gherkins Given I am at Weather Search Form Screen When I enter city search for “London” Then I should be at Weather Details Page And I wait to see “London” And I wait to see “53” step("I enter city search for ”(.*?)””) { (matches: [String]) in let weatherSearchPage = WeatherSearchPage(testCase: self.test) weatherSearchPage.userSearchForCity(matches.first!) } struct WeatherSearchPage{ func userSearchForCity(city: String){ let app = XCUIApplication() let searchField = app.searchFields[“Search a city”] searchField.tap() searchField.typeText(city) app.buttons[“Search”].tap() } }
  • 29. 3. Use Gherkins Given I am at Weather Search Form Page When I enter city search for “London” Then I should be at Weather Details Page And I wait to see “London” And I wait to see “53” step("I (am|should be) at Weather Details Page”) { WeatherDetailsPage(testCase: self.test) } struct WeatherDetailsPage{ init(testCase: XCTestCase){ testCase.expectationForPredicate( NSPredicate(format: “exists == 1”), evaluatedWithObject: XCUIApplication().otherElements[“Weather Forecast”], handler: nil ) testCase.waitForExpectationsWithTimeout(5, handler: nil) } }
  • 30. 3. Use Gherkins Given I am at Weather Search Form Page When I enter city search for “London” Then I should be at Weather Details Page And I wait to see “London” And I wait to see “53” step("I wait to see ”(.*?)””) { (matches: [String]) in self.test.expectationForPredicate( NSPredicate(format: “exists == 1”), evaluatedWithObject: XCUIApplication().staticTexts[matches.first!], handler: nil ) self.test.waitForExpectationsWithTimeout(5, handler: nil) }
  • 31. 3. Use Gherkins Given I am at Weather Search Form Page When I enter city search for “NotACity” Then I wait to see “Error” Then I wait to see “Unable to …” Then I tap on alert button “OK” step("I tap on alert button ”(.*?)””) { XCUIApplication().buttons[matches.first!].tap() }
  • 32. 3. Use Gherkins Using an additional pod to simply statements - https://github.com/joemasilotti/JAMTestHelper Gherkin
  • 33. 3. Use Gherkins Using an additional pod to simply statements - https://github.com/joemasilotti/JAMTestHelper Gherkin
  • 39. Gherkin - Using Feature File 3. Use Gherkins
  • 40. Why should I use Gherkin with XCUITest? 3. Use Gherkins • Acceptance Test Driven Development • Cross platform testing is still possible without need for 3rd party tools • Objective C + Swift

Editor's Notes

  1. The codes mentioned in the later slides can be found here show of hands: How Many people in the room are testers, developers, non-technical How many developers write Unit Tests? UI Automated Tests?
  2. Based on a couple of requirements, we will attempt to write XCUITest cases. Introducing the Gherkin Language and how we can bring this tool to XCUITest Wanted to share a segment on setting up fixtures for XCUITest
  3. Out of the box test automation Tool introduced in Xcode7. the way you would write tests is by querying for elements/subviews on the main app window XCUITest uses the XCTest framework which generally xUnitTest patterns. (abt testCases, setup/teardown, assertion when we run XCUITest, we build/install testTargetApp + testRunner. TestsR will launch+query elements on screen (blackbox) No Mocking
  4. Helpful for developers to discover how to use the api Look at the codes… explain
  5. you’ll mainly be working with XCUIElement
  6. you can also use “other elements’ to return a collection of anything that is subclass of UIView
  7. Now that you have some idea of what the api can do, lets go ahead and write our first XCUITest case!
  8. show the plus sign before running
  9. We will record the test case for the first requirement for Valid city One importantly tip here, you may want to click on the elements during recordings as Xcode will help generate the statements we may need to use later
  10. Explain code As u can see, Xcode may not always generate the desired codes. For this case, the codes for typing the search string is missing
  11. As you can see here…. we simply filled in the blanks for the missing/incorrect codes… and we organised them little bit
  12. You can use Scheme to manage your tests. This allows you to build tests against just 1 test target and use different scheme to decide which tests you want to run. Smoke vs Regression. Local vs Running in a particular env.
  13. of course, changing env requires you to change api target in your app If you want to change which env you want your app to be run in, you can use scheme to modify your config - ** remember to encrypt your config file before you package your .app / .ipa file
  14. If you don't know what’s Gherkin, this is an example of a feature file written in Gherkin Gherkin is a human readable syntax use to construct acceptance test cases. BDD Keywords: Feature, Scenario, (below scenario are steps) Given, When Then Today, focus on how to use Given When Then
  15. - Btw, this is taken from our iOS offline interview assignment where we ask candidates to code, and the interview panel conducts very thorough code review… Look at how you architect/decouple codes, name variables, any abuse of coding structures/design patterns, how you write tests, whether you have proper code coverage
  16. - Btw, this is taken from our iOS offline interview assignment where we ask candidates to code, and the interview panel conducts very thorough code review… Look at how you architect/decouple codes, name variables, any abuse of coding structures/design patterns, how you write tests, whether you have proper code coverage
  17. In our test case file, specify the Given When Then in a test method create a subclass of StepDefiner that evaluates the GWT steps definition
  18. Specify steps without using “GWT” specify “am” or “should be” … so that i can reuse it in Given or Then Where do i put this string? i can go to VC.viewDidLoad
  19. ATTD: Work with QA, PO. They can fill up features. 1st specify features, hook it into CI and get it to pass. in PG we asked PO to write and commit the feature before we start any work android/ios dev… u only need feature files to bind same requirements together No need to learn other programming language required by any 3rd party tool
  20. I hope you guys gotten a good picture on how to use XCUITest and Gherkin. If any of you guys need help or tips to kickstart UITest+Gherkin in your personal or company work, feel free to chat with me later during the break or buzz me via my emails