SlideShare a Scribd company logo
Introducing API Contract
and Localhost UI Tests
Kenneth Poon
https://medium.com/@kennethpoon
App Development Integration Tests
https://medium.com/@kennethpoon
https://github.com/depoon
Kenneth Poon
https://sg.linkedin.com/in/kenneth-poon-84217019
de_poon@hotmail.com
Principal Software Engineer @ SP Digital
Agile Development in iOS Development Space
Tech talk contributor in iOS Dev Scout Meetup group in Singapore
About me
Testing Testing
Past talks
https://engineers.sg/presenter/kenneth-poon--533
Testing
iOS Dev Scout
Meetup
iOS Conf SG 2019
Agile Singapore
Testing
Mobile Conf TH
Past talks
https://engineers.sg/presenter/kenneth-poon--533
iOS Dev Scout
Meetup
HackingHacking
Development
Agenda
Contract Tests (Ruby) - Cucumber API
Background and motivation for this sharing this talk
Localhost UI Test (iOS) - Swift Localhost
Background and Motivation
J2EE -> iOS Development
Not much iOS Test + CI Practices out there (2010)
Sinatra (Ruby)Calabash (Ruby) Cucumber (Ruby)
SwiftLocalhost (Swift)Cucumberish (Swift)
Life of a Mobile Developer
Mobile Developer Backend EngineerQA
I’m a mobile developer.
In terms of testing, I
write Unit tests to
ensure that my
modules are working
as expected.
I will also ensure that I
achieve high code
coverage for my native
app codes
I’m a QA engineer. I take
ownership of mobile
E2E tests.
When the mobile app
build is ready , I will
verify it in our test/QA
environment
I’m a backend engineer.
I write tests that cover
the behaviour of the
services I build.
Life of a Mobile Developer
Mobile Developer Backend Engineer
API Contract
Feature

1
Not Readyv1
v1
Life of a Mobile Developer
Mobile Developer Backend EngineerAPI Contract
Feature

1
v1
v1
Life of a Mobile Developer
Mobile Developer Backend EngineerAPI Contract
Feature

1
v1
v1
V2
v1
App Breaks - API Contract
• Contract definition has changed
• Backend Engineer may not be
aware of what services app is
consuming
• QA may only find out after running
test suite
APPLICATION
BREAKS
QA: WHAT’S HAPPENING!!
Life of a Mobile Developer
Mobile Developer
Feature

1
Life of a Mobile Developer
Mobile Developer
Feature

1
Database 3rd Party Services
App Breaks - Dependencies
• Services down
• Test Data Fixtures are not
synced up
• Engineers may only discover
broken dependencies by
running E2E tests
APPLICATION
BREAKS
QA: My E2E Tests
failed again!

What is happening
this time?
Life of a Mobile Developer
Mobile Developer QA
Life of a Mobile Developer
Mobile Developer QA
Dev, the app is breaking
very often in Test/
Staging environment
Sorry about it, QA.

My native code is
fine. It seems like
the backend
services are down
at the moment
Grrr.. it took me an hour
of tests execution just
to discover that that.
This is driving me crazy.
Other times, the backend engineer
unknowingly changed the API schema I understand but I will always find
you first whenever I discover any of
these issues.
Hmmm… let me come up with a
solution for this
About End-to-End Tests
QA
As QA, we own and take responsibility in the development
and maintenance of the mobile E2E tests
But E2E tests are very brittle
Mobile Apps typically have multiple dependencies
Difficult to write tests that are dependent on shared
resources
E2E Tests are generally slow and expensive
Even if we can write E2E tests, we may not be
able to achieve comprehensive UI Automation
test coverage
Test Pyramid
Unit Tests
E2E Tests
Integration
Tests
XCUITest / Appium
XCTest / JUnit
API Contract Tests
Mock Response Tests
Integration Tests
Api Contract Tests
Mock
Mock Response Tests
Mock
Localhost
Localhost XCUITest - iOS SwiftLocalhost
Setup 

Swift Localhost
Tests
Unit Tests
E2E Tests
Integration
Tests
Mock Response Tests
L
A
I
M
[Localhost] Setup in-memory localhost server
[API] Redirect API calls to localhost server
[Info.plist] Patch Info.plist
[Mock] Setup mock responses
Setup Localhost
Setup Localhost - [Localhost]
Localhost
Server
Use a unique port number
Setup an in-memory server in the test runner
Setup and tear down localhost server when
executing each test
import XCTest
class MovieListTest: XCTestCase {
}
import SwiftLocalhost
var localhostServer: LocalhostServer!
override func setUp() {
}
self.localhostServer =
LocalhostServer(portNumber: 9001)
self.localhostServer.startListening()
override func tearDown() {
}
Setup Localhost - [Localhost]
self.localhostServer.stopListening()
self.localhostServer =
LocalhostServer.initializeUsingRandomPortNumber()
Setup Localhost - [API]
Localhost
Server
Actual
Server
Update URL Domain to localhost

(with port number)
private let baseUrl: String = "http://localhost:9001/3/movie"
Setup Localhost - [API]
class NetworkOperations {
}
private let baseUrl: String = "https://api.themoviedb.org/3/movie"//private let baseUrl: String = "https://api.themoviedb.org/3/movie"
Setup Localhost - [Info.plist]
Localhost
Server Update Info.plist
iOS >=10
iOS 9
path["/login"] = {

“status" = "login successful"

}
path["/movies"] = [

{

"title": "Batman",

"subtitle": "XXX"

},

{

“title": "Matrix",

"subtitle: "YYY"

},

]
Setup Mock
Responses
Setup Localhost - [Mock]
Localhost
Server
func testMoviePopularList() {



}




XCUIApplication().launch()
//Add XCUITest Codes
Setup Localhost - [Mock]




self.localhostServer.route(method: .GET,
path: "/3/movie/popular",
responseJsonFileName: "home_popular")


Asserting
Localhost
Requests
Unit Tests
E2E Tests
Integration
Tests
Mock Response Tests
List
Asserting Localhost Requests
Use case
1. Listing View
Item List Request
Localhost Requests
Asserting Localhost Requests
Use case
1. Listing View
2. Detail View Item List Request
Localhost Requests
Detail
Item Detail Request
Asserting Localhost Requests
Use case
1. Listing View
2. Detail View Item List Request
Localhost Requests
Detail
Item Detail Request
3. Bookmark Item
Bookmark Item Request
Expected Requests Order
Asserting Localhost Requests
public class LocalhostServer {
public var recordedRequests: [URLRequest]
}
LocalhostServer records all received URLRequest(s)
Asserting Localhost Requests
//#### By URL Paths---------




let expectedRequestPaths: [String] = [
"/3/movie/popular",
"/identitytoolkit/v3/relyingparty/verifyPassword",
"/identitytoolkit/v3/relyingparty/getAccountInfo"
]






let actualRequestPaths = self.localhostServer.recordedRequests.map {
return $0.url!.path
}






XCTAssertEqual(expectedRequestPaths, actualRequestPaths)


let expectedCURLs: [String] = [
"curl -X GET ’http://localhost:9001/3/movie/popular?api_key=71b'",
"curl -X POST ’http://localhost:9001/relyingparty/verifyPassword?
key=AIzaSy' -d '{n "email" : "apple@gmail.com",n "password" :
"password"}'",
"curl -X POST ’http://localhost:9001/relyingparty/getAccountInfo?
key=AIzaSy' -d '{n "idToken" : "eyJhbj"n}'"
]




let expectedCURLs: [String] = [
"curl -X GET ’http://localhost:9001/3/movie/popular?api_key=71b'",
"curl -X POST ’http://localhost:9001/relyingparty/verifyPassword?
key=AIzaSy' -d '{n "email" : "apple@gmail.com",n "password" :
"password"}'",
"curl -X POST ’http://localhost:9001/relyingparty/getAccountInfo?
key=AIzaSy' -d '{n "idToken" : "eyJhbj"n}'"
]




let actualCURLs = self.localhostServer.recordedRequests.map {
return $0.cURL(withHeaders: false)
}
Asserting Localhost Requests
//#### By describing cURL commands ---------








XCTAssertEqual(expectedCURLs, actualCURLs)


let expectedCURLs: [String] = [
"curl -X GET ’http://localhost:9001/3/movie/popular?api_key=71b'",
"curl -X POST ’http://localhost:9001/relyingparty/verifyPassword?
key=AIzaSy' -d '{n "email" : "apple@gmail.com",n "password" :
"password"}'",
"curl -X POST ’http://localhost:9001/relyingparty/getAccountInfo?
key=AIzaSy' -d '{n "idToken" : "eyJhbj"n}'"
]


https://github.com/mkamhawi/ios-movies-app [orginal]
Special Thanks to

Mohamed El-Kamhawi
https://github.com/depoon/ios-movies-app [forked]


Swift Localhost
Demo
Unit Tests
E2E Tests
Integration
Tests
Mock Response Tests
FAQ on Localhost UITests
Why can’t we add stub responses in the code?
Localhost
Server
Mock
HTTP
TCP
HTTP
TCP
Mock

Response
FAQ on Localhost UITests
Swift Localhost Vapor (Swift)
WireMock (Java)
Typicode (JS)
Sinatra (Ruby)
What are the advantages of using Swift Localhost over other localhost
web server solutions?
FAQ
Swift Localhost
Vapor (Swift)
WireMock (Java)
Typicode (JS)
Sinatra (Ruby)
What are the advantages of using Swift Localhost over other localhost
web server solutions?
FAQ on Localhost UITests
Swift Localhost
Vapor (Swift)
WireMock (Java)
Typicode (JS)
Sinatra (Ruby)
What are the advantages of using Swift Localhost over other localhost
web server solutions?
Advantages
✓ Easy Installation and Setup via Cocoapods

✓ Use Swift to setup mock server

✓ In line mock responses in the same test scope

✓ Use same runtime XCode debugger

✓ Ctrl + U
FAQ
How does the Localhost UITest technique fit in my development
process?
List
2. Fetch list of items using server/list api
1. Navigate to List view
3. Tap on 1st Item. App navigates to Detail view
4. Fetch item detail using server/detail api
5. Bookmark item
6. Bookmark item detail using
server/bookmark api
Bookmarking Use Case
DetailDetail
server/list
server/detail
server/bookmark
7. Assert Bookmark Icon is correctly reflected
FAQ
How does the Localhost XCUITest technique fit in my development
process?
Detail
server/list
server/detail
server/bookmark
Localhost Mock Responses
Test Case
1. Navigate to List view
2. Tap on 1st Item. App navigates to Detail view
3. Bookmark item
4. Assert Bookmark Icon is correctly reflected
Never Ever Fails
✓ Early Development
✓ Use Case Wont Fail
API Contract
Tests
Unit Tests
E2E Tests
Integration
Tests
API Contract Tests
API Contract Tests
Mobile Developer QA
Dev, I know it’s great
that you have Mock
Response Tests that
never fails.
But the APIs do change
and they might break
the app.
Yes, QA. You are
absolutely right
API Contract
v1
But our app
releases are
bounded by the
pre-agreed
APIContracts
We can write a script to ensure the
APIs are working as agreed upon
We can use this script to discover
which services are affecting the app.
API Contract Tests
API Contract
v1
API Contract Tests
API Contract
v1 /v1/login -> schema1_v1
/v1/shoppingList -> schema2_v1
/v1/productDetails -> schema3_v1
/v1/productDetails -> schema4_v1
API Contract Script
v1 v1.1 V2
/v1/productDetails -> schema3_v2
Mobile Developer
Gotcha! Latest
API deployment
broke our app
API Contract Tests
Backend Engineer
Hey Mobile Dev,
Why are you writing
tests against my
API? Shouldn’t I be
the one responsible
for that?
Mobile Developer
Our app will
perform correctly
only when
dependent services
are working as
expected.
Our API Contract tests will give you quick feedback
whenever deployed services break the contracts
Mobile developers will be responsible to maintain
tests that describe the services the app consume.
API Contract Tests
Backend Engineer
That sounds
awesome to me.
You know what? I
think we should
automatically
trigger the API
Contract tests
every time we
deploy any changes
Mobile Developer
Nice! This encourages backend developers to
deploy changes without worrying whether it
will affect the mobile app clients.
… BECAUSE WE WILL CATCH ANY BREAKING CHANGES
API Contract Tests
Mobile Developer QA
Dev, I feel annoyed that
after running my tests, I
discover my test
fixtures are not ready
(or incorrect).



eg. Login credentials,
Product Details on
Staging environment
are incorrect
Your test cases
actually describe
the request/
response exchange
that will be
expected.
We can write API Contract tests that chain the order
of API requests that simulates a use case on the app
You can simply run the API Contract tests before any
automated/manual execution of tests. This will give
you a headsup whether your tests will fail
Since API Contract tests are generally fast, you will
get your feedback in no time.
Wow, this sounds
awesome. I am
eager to have a go
at it
Introducing

Cucumber API
Unit Tests
E2E Tests
Integration
Tests
API Contract Tests
What is your take on API Contract Tests (ACT)
Mobile Developer Backend EngineerQA
ACT checks whether
our app dependencies
are working as
expected.
The contract definition
aids us in designing
our localhost tests
ACT is a cheap and fast
way for QA to ensure
that all dependencies,
including data fixtures
are ready before we
start testing.

The fast feedback saves
us time especially when
we can get feedback
within seconds
With ACT, I have more
confidence to refactor
my code base.



We are now
encouraged to run ACT
tied to released app
versions and check if
older versions will be
broken by new API code
deployments
Closing
Consider having both Mock Response and API Contract Tests
Integration tests are meant to compliment but not replace E2E
API Contract Tests is the low hanging fruit
Confidently run localhost tests to verify that native app codes is
working under normal, valid conditions
It may be difficult (but not impossible) to mock services used by 3rd party
services.
Do visit your existing tools and see how you can bring integration tests
into your development
https://medium.com/better-programming/how-to-import-
swift-urlrequests-into-postman-ef6c65c20834
https://github.com/depoon/SwiftLocalhost
https://github.com/hidroh/cucumber-api
https://github.com/depoon/ios-movies-app
Demo App
Import Swift URLRequests into Postman
Setting up Swift localhost for testing
Cucumber API
References
References
https://bit.ly/2ZbDcA3
https://medium.com/@kennethpoon
Questions

More Related Content

What's hot

Ios driver presentation copy
Ios driver presentation copyIos driver presentation copy
Ios driver presentation copyDavid O'Dowd
 
Do's and Do not's about p2
Do's and Do not's about p2Do's and Do not's about p2
Do's and Do not's about p2
Pascal Rapicault
 
利用 Appium + Robot Framework 實現跨平台 App 互動測試
利用 Appium + Robot Framework 實現跨平台 App 互動測試利用 Appium + Robot Framework 實現跨平台 App 互動測試
利用 Appium + Robot Framework 實現跨平台 App 互動測試
Jeremy Kao
 
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
VitaliyMakogon
 
Using the latest Java Persistence API 2 Features - Tech Days 2010 India
Using the latest Java Persistence API 2 Features - Tech Days 2010 IndiaUsing the latest Java Persistence API 2 Features - Tech Days 2010 India
Using the latest Java Persistence API 2 Features - Tech Days 2010 India
Arun Gupta
 
JavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In DepthJavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In Depth
Danno Ferrin
 
Thinking tts - Eric Floe
Thinking tts - Eric FloeThinking tts - Eric Floe
Thinking tts - Eric Floe
Eric Floe
 
Uber mobility - Build & Release
Uber mobility - Build & ReleaseUber mobility - Build & Release
Uber mobility - Build & Release
Dhaval Patel
 
Uber Mobility Meetup: Mobile Testing
Uber Mobility Meetup:  Mobile TestingUber Mobility Meetup:  Mobile Testing
Uber Mobility Meetup: Mobile Testing
Apple Chow
 
Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:winConsole Apps: php artisan forthe:win
Console Apps: php artisan forthe:win
Joe Ferguson
 
Apache Cordova: Overview and Introduction
Apache Cordova: Overview and IntroductionApache Cordova: Overview and Introduction
Apache Cordova: Overview and Introduction
Gabriele Falasca
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android
Hazem Saleh
 
Codestrong 2012 breakout session exploring the new titanium command line in...
Codestrong 2012 breakout session   exploring the new titanium command line in...Codestrong 2012 breakout session   exploring the new titanium command line in...
Codestrong 2012 breakout session exploring the new titanium command line in...Axway Appcelerator
 
iPhone Coding For Web Developers
iPhone Coding For Web DevelopersiPhone Coding For Web Developers
iPhone Coding For Web Developers
Matt Biddulph
 
Observability and Troubleshooting in Forge
Observability and Troubleshooting in ForgeObservability and Troubleshooting in Forge
Observability and Troubleshooting in Forge
Atlassian
 
Dominik Veselý - Vše co jste kdy chtěli vědět o CI a báli jste se zeptat
Dominik Veselý - Vše co jste kdy chtěli vědět o CI a báli jste se zeptatDominik Veselý - Vše co jste kdy chtěli vědět o CI a báli jste se zeptat
Dominik Veselý - Vše co jste kdy chtěli vědět o CI a báli jste se zeptat
mdevtalk
 
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QAFest
 
Cross Platform Native Development with Appcelerator Titanium (2015 DevNexus)
Cross Platform Native Development with Appcelerator Titanium (2015 DevNexus)Cross Platform Native Development with Appcelerator Titanium (2015 DevNexus)
Cross Platform Native Development with Appcelerator Titanium (2015 DevNexus)
Stephen Feather
 
[E-Dev-Day-US-2015][9/9] High Level Application Development with Elua (Daniel...
[E-Dev-Day-US-2015][9/9] High Level Application Development with Elua (Daniel...[E-Dev-Day-US-2015][9/9] High Level Application Development with Elua (Daniel...
[E-Dev-Day-US-2015][9/9] High Level Application Development with Elua (Daniel...
EnlightenmentProject
 

What's hot (20)

Ios driver presentation copy
Ios driver presentation copyIos driver presentation copy
Ios driver presentation copy
 
Do's and Do not's about p2
Do's and Do not's about p2Do's and Do not's about p2
Do's and Do not's about p2
 
利用 Appium + Robot Framework 實現跨平台 App 互動測試
利用 Appium + Robot Framework 實現跨平台 App 互動測試利用 Appium + Robot Framework 實現跨平台 App 互動測試
利用 Appium + Robot Framework 實現跨平台 App 互動測試
 
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
 
Using the latest Java Persistence API 2 Features - Tech Days 2010 India
Using the latest Java Persistence API 2 Features - Tech Days 2010 IndiaUsing the latest Java Persistence API 2 Features - Tech Days 2010 India
Using the latest Java Persistence API 2 Features - Tech Days 2010 India
 
JavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In DepthJavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In Depth
 
Thinking tts - Eric Floe
Thinking tts - Eric FloeThinking tts - Eric Floe
Thinking tts - Eric Floe
 
Uber mobility - Build & Release
Uber mobility - Build & ReleaseUber mobility - Build & Release
Uber mobility - Build & Release
 
Uber Mobility Meetup: Mobile Testing
Uber Mobility Meetup:  Mobile TestingUber Mobility Meetup:  Mobile Testing
Uber Mobility Meetup: Mobile Testing
 
Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:winConsole Apps: php artisan forthe:win
Console Apps: php artisan forthe:win
 
Testdroid:
Testdroid: Testdroid:
Testdroid:
 
Apache Cordova: Overview and Introduction
Apache Cordova: Overview and IntroductionApache Cordova: Overview and Introduction
Apache Cordova: Overview and Introduction
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android
 
Codestrong 2012 breakout session exploring the new titanium command line in...
Codestrong 2012 breakout session   exploring the new titanium command line in...Codestrong 2012 breakout session   exploring the new titanium command line in...
Codestrong 2012 breakout session exploring the new titanium command line in...
 
iPhone Coding For Web Developers
iPhone Coding For Web DevelopersiPhone Coding For Web Developers
iPhone Coding For Web Developers
 
Observability and Troubleshooting in Forge
Observability and Troubleshooting in ForgeObservability and Troubleshooting in Forge
Observability and Troubleshooting in Forge
 
Dominik Veselý - Vše co jste kdy chtěli vědět o CI a báli jste se zeptat
Dominik Veselý - Vše co jste kdy chtěli vědět o CI a báli jste se zeptatDominik Veselý - Vše co jste kdy chtěli vědět o CI a báli jste se zeptat
Dominik Veselý - Vše co jste kdy chtěli vědět o CI a báli jste se zeptat
 
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
 
Cross Platform Native Development with Appcelerator Titanium (2015 DevNexus)
Cross Platform Native Development with Appcelerator Titanium (2015 DevNexus)Cross Platform Native Development with Appcelerator Titanium (2015 DevNexus)
Cross Platform Native Development with Appcelerator Titanium (2015 DevNexus)
 
[E-Dev-Day-US-2015][9/9] High Level Application Development with Elua (Daniel...
[E-Dev-Day-US-2015][9/9] High Level Application Development with Elua (Daniel...[E-Dev-Day-US-2015][9/9] High Level Application Development with Elua (Daniel...
[E-Dev-Day-US-2015][9/9] High Level Application Development with Elua (Daniel...
 

Similar to Mobile Development integration tests

Expo - Zero to App.pptx
Expo - Zero to App.pptxExpo - Zero to App.pptx
Expo - Zero to App.pptx
😎 Anthony Kariuki
 
Seattle StrongLoop Node.js Workshop
Seattle StrongLoop Node.js WorkshopSeattle StrongLoop Node.js Workshop
Seattle StrongLoop Node.js Workshop
Jimmy Guerrero
 
Fixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaFixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaChristian Heilmann
 
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Applitools
 
Appium solution
Appium solutionAppium solution
Appium solution
Nael Abd Eljawad
 
Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)True-Vision
 
State ofappdevelopment
State ofappdevelopmentState ofappdevelopment
State ofappdevelopment
gillygize
 
Java Test Automation for REST, Web and Mobile
Java Test Automation for REST, Web and MobileJava Test Automation for REST, Web and Mobile
Java Test Automation for REST, Web and Mobile
Elias Nogueira
 
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaCloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Amazon Web Services
 
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
Srijan Technologies
 
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
Badoo
 
The Present and Future of Mobile Test Automation with Appium
The Present and Future of Mobile Test Automation with AppiumThe Present and Future of Mobile Test Automation with Appium
The Present and Future of Mobile Test Automation with Appium
TechWell
 
Dev ops for cross platform mobile modeveast 12
Dev ops for cross platform mobile   modeveast 12Dev ops for cross platform mobile   modeveast 12
Dev ops for cross platform mobile modeveast 12
Sanjeev Sharma
 
Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine
Ruby on Google App Engine: Upgrade to Google App "Turbo" EngineRuby on Google App Engine: Upgrade to Google App "Turbo" Engine
Ruby on Google App Engine: Upgrade to Google App "Turbo" EngineJoseph Ku
 
Deploying applications to Cloud with Google App Engine
Deploying applications to Cloud with Google App EngineDeploying applications to Cloud with Google App Engine
Deploying applications to Cloud with Google App Engine
Alexander Zamkovyi
 
Robot Framework Introduction & Sauce Labs Integration
Robot Framework Introduction & Sauce Labs IntegrationRobot Framework Introduction & Sauce Labs Integration
Robot Framework Introduction & Sauce Labs Integration
Sauce Labs
 
Launch Arguments & NSUserDefaults by Franck Lefebvre
Launch Arguments & NSUserDefaults by Franck LefebvreLaunch Arguments & NSUserDefaults by Franck Lefebvre
Launch Arguments & NSUserDefaults by Franck Lefebvre
CocoaHeads France
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
Jim Jeffers
 
Play Support in Cloud Foundry
Play Support in Cloud FoundryPlay Support in Cloud Foundry
Play Support in Cloud Foundry
rajdeep
 
All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$
Joe Ferguson
 

Similar to Mobile Development integration tests (20)

Expo - Zero to App.pptx
Expo - Zero to App.pptxExpo - Zero to App.pptx
Expo - Zero to App.pptx
 
Seattle StrongLoop Node.js Workshop
Seattle StrongLoop Node.js WorkshopSeattle StrongLoop Node.js Workshop
Seattle StrongLoop Node.js Workshop
 
Fixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaFixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World Romania
 
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
 
Appium solution
Appium solutionAppium solution
Appium solution
 
Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)
 
State ofappdevelopment
State ofappdevelopmentState ofappdevelopment
State ofappdevelopment
 
Java Test Automation for REST, Web and Mobile
Java Test Automation for REST, Web and MobileJava Test Automation for REST, Web and Mobile
Java Test Automation for REST, Web and Mobile
 
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaCloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
 
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
 
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...
 
The Present and Future of Mobile Test Automation with Appium
The Present and Future of Mobile Test Automation with AppiumThe Present and Future of Mobile Test Automation with Appium
The Present and Future of Mobile Test Automation with Appium
 
Dev ops for cross platform mobile modeveast 12
Dev ops for cross platform mobile   modeveast 12Dev ops for cross platform mobile   modeveast 12
Dev ops for cross platform mobile modeveast 12
 
Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine
Ruby on Google App Engine: Upgrade to Google App "Turbo" EngineRuby on Google App Engine: Upgrade to Google App "Turbo" Engine
Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine
 
Deploying applications to Cloud with Google App Engine
Deploying applications to Cloud with Google App EngineDeploying applications to Cloud with Google App Engine
Deploying applications to Cloud with Google App Engine
 
Robot Framework Introduction & Sauce Labs Integration
Robot Framework Introduction & Sauce Labs IntegrationRobot Framework Introduction & Sauce Labs Integration
Robot Framework Introduction & Sauce Labs Integration
 
Launch Arguments & NSUserDefaults by Franck Lefebvre
Launch Arguments & NSUserDefaults by Franck LefebvreLaunch Arguments & NSUserDefaults by Franck Lefebvre
Launch Arguments & NSUserDefaults by Franck Lefebvre
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
 
Play Support in Cloud Foundry
Play Support in Cloud FoundryPlay Support in Cloud Foundry
Play Support in Cloud Foundry
 
All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$
 

More from 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
 
iOS Automation: XCUITest + Gherkin
iOS Automation: XCUITest + GherkiniOS Automation: XCUITest + Gherkin
iOS Automation: XCUITest + Gherkin
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)

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)
 
iOS Automation: XCUITest + Gherkin
iOS Automation: XCUITest + GherkiniOS Automation: XCUITest + Gherkin
iOS Automation: XCUITest + Gherkin
 
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

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
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
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
 
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
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
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
 
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
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
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
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 

Recently uploaded (20)

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
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
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
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
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
 
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...
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
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
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 

Mobile Development integration tests

  • 1. Introducing API Contract and Localhost UI Tests Kenneth Poon https://medium.com/@kennethpoon App Development Integration Tests
  • 2. https://medium.com/@kennethpoon https://github.com/depoon Kenneth Poon https://sg.linkedin.com/in/kenneth-poon-84217019 de_poon@hotmail.com Principal Software Engineer @ SP Digital Agile Development in iOS Development Space Tech talk contributor in iOS Dev Scout Meetup group in Singapore About me
  • 3. Testing Testing Past talks https://engineers.sg/presenter/kenneth-poon--533 Testing iOS Dev Scout Meetup iOS Conf SG 2019 Agile Singapore Testing Mobile Conf TH
  • 5. Agenda Contract Tests (Ruby) - Cucumber API Background and motivation for this sharing this talk Localhost UI Test (iOS) - Swift Localhost
  • 6. Background and Motivation J2EE -> iOS Development Not much iOS Test + CI Practices out there (2010) Sinatra (Ruby)Calabash (Ruby) Cucumber (Ruby) SwiftLocalhost (Swift)Cucumberish (Swift)
  • 7. Life of a Mobile Developer Mobile Developer Backend EngineerQA I’m a mobile developer. In terms of testing, I write Unit tests to ensure that my modules are working as expected. I will also ensure that I achieve high code coverage for my native app codes I’m a QA engineer. I take ownership of mobile E2E tests. When the mobile app build is ready , I will verify it in our test/QA environment I’m a backend engineer. I write tests that cover the behaviour of the services I build.
  • 8. Life of a Mobile Developer Mobile Developer Backend Engineer API Contract Feature
 1 Not Readyv1 v1
  • 9. Life of a Mobile Developer Mobile Developer Backend EngineerAPI Contract Feature
 1 v1 v1
  • 10. Life of a Mobile Developer Mobile Developer Backend EngineerAPI Contract Feature
 1 v1 v1 V2 v1 App Breaks - API Contract • Contract definition has changed • Backend Engineer may not be aware of what services app is consuming • QA may only find out after running test suite APPLICATION BREAKS QA: WHAT’S HAPPENING!!
  • 11. Life of a Mobile Developer Mobile Developer Feature
 1
  • 12. Life of a Mobile Developer Mobile Developer Feature
 1 Database 3rd Party Services App Breaks - Dependencies • Services down • Test Data Fixtures are not synced up • Engineers may only discover broken dependencies by running E2E tests APPLICATION BREAKS QA: My E2E Tests failed again!
 What is happening this time?
  • 13. Life of a Mobile Developer Mobile Developer QA
  • 14. Life of a Mobile Developer Mobile Developer QA Dev, the app is breaking very often in Test/ Staging environment Sorry about it, QA.
 My native code is fine. It seems like the backend services are down at the moment Grrr.. it took me an hour of tests execution just to discover that that. This is driving me crazy. Other times, the backend engineer unknowingly changed the API schema I understand but I will always find you first whenever I discover any of these issues. Hmmm… let me come up with a solution for this
  • 15. About End-to-End Tests QA As QA, we own and take responsibility in the development and maintenance of the mobile E2E tests But E2E tests are very brittle Mobile Apps typically have multiple dependencies Difficult to write tests that are dependent on shared resources E2E Tests are generally slow and expensive Even if we can write E2E tests, we may not be able to achieve comprehensive UI Automation test coverage
  • 16. Test Pyramid Unit Tests E2E Tests Integration Tests XCUITest / Appium XCTest / JUnit API Contract Tests Mock Response Tests
  • 17. Integration Tests Api Contract Tests Mock Mock Response Tests Mock Localhost Localhost XCUITest - iOS SwiftLocalhost
  • 18. Setup 
 Swift Localhost Tests Unit Tests E2E Tests Integration Tests Mock Response Tests
  • 19. L A I M [Localhost] Setup in-memory localhost server [API] Redirect API calls to localhost server [Info.plist] Patch Info.plist [Mock] Setup mock responses Setup Localhost
  • 20. Setup Localhost - [Localhost] Localhost Server Use a unique port number Setup an in-memory server in the test runner Setup and tear down localhost server when executing each test
  • 21. import XCTest class MovieListTest: XCTestCase { } import SwiftLocalhost var localhostServer: LocalhostServer! override func setUp() { } self.localhostServer = LocalhostServer(portNumber: 9001) self.localhostServer.startListening() override func tearDown() { } Setup Localhost - [Localhost] self.localhostServer.stopListening() self.localhostServer = LocalhostServer.initializeUsingRandomPortNumber()
  • 22. Setup Localhost - [API] Localhost Server Actual Server Update URL Domain to localhost
 (with port number)
  • 23. private let baseUrl: String = "http://localhost:9001/3/movie" Setup Localhost - [API] class NetworkOperations { } private let baseUrl: String = "https://api.themoviedb.org/3/movie"//private let baseUrl: String = "https://api.themoviedb.org/3/movie"
  • 24. Setup Localhost - [Info.plist] Localhost Server Update Info.plist iOS >=10 iOS 9
  • 25. path["/login"] = {
 “status" = "login successful"
 } path["/movies"] = [
 {
 "title": "Batman",
 "subtitle": "XXX" },
 {
 “title": "Matrix",
 "subtitle: "YYY" },
 ] Setup Mock Responses Setup Localhost - [Mock] Localhost Server
  • 26. func testMoviePopularList() {
 
 } 
 
 XCUIApplication().launch() //Add XCUITest Codes Setup Localhost - [Mock] 
 
 self.localhostServer.route(method: .GET, path: "/3/movie/popular", responseJsonFileName: "home_popular")
  • 28. List Asserting Localhost Requests Use case 1. Listing View Item List Request Localhost Requests
  • 29. Asserting Localhost Requests Use case 1. Listing View 2. Detail View Item List Request Localhost Requests Detail Item Detail Request
  • 30. Asserting Localhost Requests Use case 1. Listing View 2. Detail View Item List Request Localhost Requests Detail Item Detail Request 3. Bookmark Item Bookmark Item Request Expected Requests Order
  • 31. Asserting Localhost Requests public class LocalhostServer { public var recordedRequests: [URLRequest] } LocalhostServer records all received URLRequest(s)
  • 32. Asserting Localhost Requests //#### By URL Paths--------- 
 
 let expectedRequestPaths: [String] = [ "/3/movie/popular", "/identitytoolkit/v3/relyingparty/verifyPassword", "/identitytoolkit/v3/relyingparty/getAccountInfo" ] 
 
 
 let actualRequestPaths = self.localhostServer.recordedRequests.map { return $0.url!.path } 
 
 
 XCTAssertEqual(expectedRequestPaths, actualRequestPaths)
  • 33. 
 let expectedCURLs: [String] = [ "curl -X GET ’http://localhost:9001/3/movie/popular?api_key=71b'", "curl -X POST ’http://localhost:9001/relyingparty/verifyPassword? key=AIzaSy' -d '{n "email" : "apple@gmail.com",n "password" : "password"}'", "curl -X POST ’http://localhost:9001/relyingparty/getAccountInfo? key=AIzaSy' -d '{n "idToken" : "eyJhbj"n}'" ] 
 
 let expectedCURLs: [String] = [ "curl -X GET ’http://localhost:9001/3/movie/popular?api_key=71b'", "curl -X POST ’http://localhost:9001/relyingparty/verifyPassword? key=AIzaSy' -d '{n "email" : "apple@gmail.com",n "password" : "password"}'", "curl -X POST ’http://localhost:9001/relyingparty/getAccountInfo? key=AIzaSy' -d '{n "idToken" : "eyJhbj"n}'" ] 
 
 let actualCURLs = self.localhostServer.recordedRequests.map { return $0.cURL(withHeaders: false) } Asserting Localhost Requests //#### By describing cURL commands --------- 
 
 
 
 XCTAssertEqual(expectedCURLs, actualCURLs) 
 let expectedCURLs: [String] = [ "curl -X GET ’http://localhost:9001/3/movie/popular?api_key=71b'", "curl -X POST ’http://localhost:9001/relyingparty/verifyPassword? key=AIzaSy' -d '{n "email" : "apple@gmail.com",n "password" : "password"}'", "curl -X POST ’http://localhost:9001/relyingparty/getAccountInfo? key=AIzaSy' -d '{n "idToken" : "eyJhbj"n}'" ] 

  • 34. https://github.com/mkamhawi/ios-movies-app [orginal] Special Thanks to
 Mohamed El-Kamhawi https://github.com/depoon/ios-movies-app [forked] 
 Swift Localhost Demo Unit Tests E2E Tests Integration Tests Mock Response Tests
  • 35. FAQ on Localhost UITests Why can’t we add stub responses in the code? Localhost Server Mock HTTP TCP HTTP TCP Mock
 Response
  • 36. FAQ on Localhost UITests Swift Localhost Vapor (Swift) WireMock (Java) Typicode (JS) Sinatra (Ruby) What are the advantages of using Swift Localhost over other localhost web server solutions?
  • 37. FAQ Swift Localhost Vapor (Swift) WireMock (Java) Typicode (JS) Sinatra (Ruby) What are the advantages of using Swift Localhost over other localhost web server solutions?
  • 38. FAQ on Localhost UITests Swift Localhost Vapor (Swift) WireMock (Java) Typicode (JS) Sinatra (Ruby) What are the advantages of using Swift Localhost over other localhost web server solutions? Advantages ✓ Easy Installation and Setup via Cocoapods ✓ Use Swift to setup mock server ✓ In line mock responses in the same test scope ✓ Use same runtime XCode debugger ✓ Ctrl + U
  • 39. FAQ How does the Localhost UITest technique fit in my development process? List 2. Fetch list of items using server/list api 1. Navigate to List view 3. Tap on 1st Item. App navigates to Detail view 4. Fetch item detail using server/detail api 5. Bookmark item 6. Bookmark item detail using server/bookmark api Bookmarking Use Case DetailDetail server/list server/detail server/bookmark 7. Assert Bookmark Icon is correctly reflected
  • 40. FAQ How does the Localhost XCUITest technique fit in my development process? Detail server/list server/detail server/bookmark Localhost Mock Responses Test Case 1. Navigate to List view 2. Tap on 1st Item. App navigates to Detail view 3. Bookmark item 4. Assert Bookmark Icon is correctly reflected Never Ever Fails ✓ Early Development ✓ Use Case Wont Fail
  • 41. API Contract Tests Unit Tests E2E Tests Integration Tests API Contract Tests
  • 42. API Contract Tests Mobile Developer QA Dev, I know it’s great that you have Mock Response Tests that never fails. But the APIs do change and they might break the app. Yes, QA. You are absolutely right API Contract v1 But our app releases are bounded by the pre-agreed APIContracts We can write a script to ensure the APIs are working as agreed upon We can use this script to discover which services are affecting the app.
  • 43. API Contract Tests API Contract v1
  • 44. API Contract Tests API Contract v1 /v1/login -> schema1_v1 /v1/shoppingList -> schema2_v1 /v1/productDetails -> schema3_v1 /v1/productDetails -> schema4_v1 API Contract Script v1 v1.1 V2 /v1/productDetails -> schema3_v2 Mobile Developer Gotcha! Latest API deployment broke our app
  • 45. API Contract Tests Backend Engineer Hey Mobile Dev, Why are you writing tests against my API? Shouldn’t I be the one responsible for that? Mobile Developer Our app will perform correctly only when dependent services are working as expected. Our API Contract tests will give you quick feedback whenever deployed services break the contracts Mobile developers will be responsible to maintain tests that describe the services the app consume.
  • 46. API Contract Tests Backend Engineer That sounds awesome to me. You know what? I think we should automatically trigger the API Contract tests every time we deploy any changes Mobile Developer Nice! This encourages backend developers to deploy changes without worrying whether it will affect the mobile app clients. … BECAUSE WE WILL CATCH ANY BREAKING CHANGES
  • 47. API Contract Tests Mobile Developer QA Dev, I feel annoyed that after running my tests, I discover my test fixtures are not ready (or incorrect).
 
 eg. Login credentials, Product Details on Staging environment are incorrect Your test cases actually describe the request/ response exchange that will be expected. We can write API Contract tests that chain the order of API requests that simulates a use case on the app You can simply run the API Contract tests before any automated/manual execution of tests. This will give you a headsup whether your tests will fail Since API Contract tests are generally fast, you will get your feedback in no time. Wow, this sounds awesome. I am eager to have a go at it
  • 48. Introducing
 Cucumber API Unit Tests E2E Tests Integration Tests API Contract Tests
  • 49. What is your take on API Contract Tests (ACT) Mobile Developer Backend EngineerQA ACT checks whether our app dependencies are working as expected. The contract definition aids us in designing our localhost tests ACT is a cheap and fast way for QA to ensure that all dependencies, including data fixtures are ready before we start testing.
 The fast feedback saves us time especially when we can get feedback within seconds With ACT, I have more confidence to refactor my code base.
 
 We are now encouraged to run ACT tied to released app versions and check if older versions will be broken by new API code deployments
  • 50. Closing Consider having both Mock Response and API Contract Tests Integration tests are meant to compliment but not replace E2E API Contract Tests is the low hanging fruit Confidently run localhost tests to verify that native app codes is working under normal, valid conditions It may be difficult (but not impossible) to mock services used by 3rd party services. Do visit your existing tools and see how you can bring integration tests into your development