SlideShare a Scribd company logo
1 of 19
Download to read offline
USER INTERFACE
TESTING
WITH KIF & SWIFT
CASE FOR UI TESTING
INTEGRATION

NAVIGATION FLOW

DATA FLOW

USER EXPERIENCE

ACCESSIBILITY

REFACTORINGS / REGRESSIONS
UI TESTING IS HARD 

AND TIME CONSUMING
UNLESS

AUTOMATED 

EASYTO MAINTAIN

FAST
NATIVE SUPPORT 

FOR UI TESTING
UI AUTOMATION (JavaScript)

XCUI (Swift/Objective C)

BASED ON UIAcessibility PROTOCOL
KIF

Keep It Functional - An iOS Functional
Testing Framework
https://github.com/kif-framework/KIF

UICONF 2016 TALK BY ELLEN SHAPIRO

https://youtu.be/hYCUy-9yq_M
OBJECTIVE C - KIFTestCase
RUNS IN APP TARGET

beforeAll, beforeEach, afterAll, afterEach

KIFUITestActor - USER ACTIONS

KIFSystemTestActor - SYSTEM/DEVICE ACTIONS
SWIFT - XCTestCase
ADD SIMPLE EXTENSION TO ACCESS
KIFUITestActor AND KIFSystemTestActor
OBJECTIVE C
[tester tapViewWithAccessibilityLabel:@"Login"];


SWIFT
tester().tapView(withAccessibilityLabel : "Login")
EXTENSIONS FOR READIBILITY
extension KIFUITestActor {
@discardableResult func waitForButton(_ label: String) -> UIView! {
let button = self.waitForTappableView(withAccessibilityLabel: label, traits:
UIAccessibilityTraitButton)
return button
}
func tapButton(_ accessibilityLabel: String, value: String) {
let button = waitForButton(accessibilityLabel, value: value)
button?.tap()
}
}
RESULT
tester().tapButton(“Login”) // or even better – tester().tapLoginButton()
PROTOCOLTO ACCESS APP DATA
public protocol UsesCoreDataDatabase {
func dbContext() -> NSManagedObjectContext
func isDbEmpty(_ context: NSManagedObjectContext) -> Bool
func deleteDbData(_ context: NSManagedObjectContext)
}
public extension UsesCoreDataDatabase {
func dbContext() -> NSManagedObjectContext {
let appDelegate: YourAppDelegate = UIApplication.shared.delegate as! YourAppDelegate
let context = appDelegate.value(forKey: "context") as! NSManagedObjectContext
XCTAssertNotNil(context)
return context!
}
func isDbEmpty(_ context: NSManagedObjectContext) -> Bool {
// access model objects from context
let count = ….
return (count == 0)
}
func deleteDbData(_ context: NSManagedObjectContext) {
// Delete data
}
CUSTOM TEST CASES
class MyTestCaseWithEmptyDatabase: KIFTestCase, UsesCoreDataDatabase {
override func beforeEach() {
let context = dbContext()
if ! sDbEmpty(context) {
let name = MyAppServices.deviceModel()
if name == "iPhone Simulator" { deleteDbData(context) } else { } // Are you sure want to delete data from device?
}
}
}
class MyTestCaseWithWizardFilled: MyTestCaseWithEmptyDatabase {
var rentAmount = “100”; var unitName= “M10”; var tenantName = “Anna"
override func beforeEach() {
super.beforeEach()
let context = dbContext()
MyWizardController.saveFromWizard(in: context, address: unitName, tenant: tenantName amount: rentAmount)
}
}
class MyTestCaseWithFixturesLoaded : MyTestCaseWithEmptyDatabase {
// load fixture data in database
}
DRY, READABLE TESTS
class PaymentTests: MyTestCaseWithWizardFilled {
func testAddPayment_fromUnitDashboard() {
// given - tenantName, unitName, today are defined as MyTestCaseWithWizardFilled class variables
let amount = “5.1”; let paymentAmount = “$5.10”
tester().tapPropertiesTabButton()
tester().tapUnit(unitName, tenant: tenantName)
tester().waitForTenantBalanceScreen(tenantName, currentBalance: "$0.00")
tester().waitForLastPaymentLine("No rent payments received", amount: “") // even this should be replaced by waitForNoLastPaymentLine
// when
tester().tapAddPaymentButton()
tester().enterOnKeyboard(amount)
tester().tapSaveButton()
// then
tester().waitForTenantBalanceScreen(tenantName, currentBalance: paymentAmount)
tester().waitForLastRentPaymentLine(today, amount: paymentAmount)
}
}
…
public extension KIFUITestActor {
/// Returns last payment line in rental unit dashboard
@discardableResult func waitForLastPaymentLine(_ date: String, amount: String) -> UIView! {
let view = waitForView("Last rent payment", value: "(date), (amount)”) // Accessibility label & accessibility value
return view
}
}
FAST
NOT REALLY
MAKE UI TESTS FASTER
class MyTestCaseWithEmptyDatabase: KIFTestCase, UsesCoreDataDatabase {
override func beforeAll() {
UIApplication.shared.keyWindow!.layer.speed = 100; // faster animations
}
}
GOTCHAS & HINTS
OCCASIONALLY CAN FAIL WITHOUT A GOOD REASON

¯_( )_/¯

BEWARE OF UITableViewCells

ADD EVERYTHING AS SUBVIEWTO .contentView

SAVE SCREENSHOTS ON TEST FAILURE

SET ENVVARIABLE WITH FOLDER LOCATION- KIF_SCREENSHOTS= …



AFTER FAILING TEST IN MODAL VIEW ALL OTHER TEST RESULTS = USELESS

do { try tester().trySomething(); // then test } catch {}
ACCESSIBILITY
https://youtu.be/no12EfZUSQo
“You have no clue about your app
accessibility until you write app UI tests
that rely on accessibility”
/ me to myself /
UIAccessibility PROTOCOL
UIAccessibilityElement CLASS
UIAccessibilityContainer PROTOCOL
UIAccessibilityTraits



BUNDLED FREE WHEN USING UIKit,JUST SET 

accessibilityLabel, accessibilityValue, accessibilityHint 

IN IB AND/OR CODE
QUESTIONS?
Jurģis Ķiršakmens
jki@jki.lv
@jki / @xjki

More Related Content

What's hot

Protocol-Oriented MVVM (extended edition)
Protocol-Oriented MVVM (extended edition)Protocol-Oriented MVVM (extended edition)
Protocol-Oriented MVVM (extended edition)Natasha Murashev
 
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwift
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwiftSwift & ReactiveX – Asynchronous Event-Based Funsies with RxSwift
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwiftAaron Douglas
 
Découvrir dtrace en ligne de commande.
Découvrir dtrace en ligne de commande.Découvrir dtrace en ligne de commande.
Découvrir dtrace en ligne de commande.CocoaHeads France
 
Reacting with ReactiveUI
Reacting with ReactiveUIReacting with ReactiveUI
Reacting with ReactiveUIkiahiska
 
Reactive Programming with RxSwift
Reactive Programming with RxSwiftReactive Programming with RxSwift
Reactive Programming with RxSwiftScott Gardner
 
Introduction to RxJS
Introduction to RxJSIntroduction to RxJS
Introduction to RxJSBrainhub
 

What's hot (9)

Hello watchOS2
Hello watchOS2 Hello watchOS2
Hello watchOS2
 
Protocol-Oriented MVVM (extended edition)
Protocol-Oriented MVVM (extended edition)Protocol-Oriented MVVM (extended edition)
Protocol-Oriented MVVM (extended edition)
 
Présentation de HomeKit
Présentation de HomeKitPrésentation de HomeKit
Présentation de HomeKit
 
NodeJs
NodeJsNodeJs
NodeJs
 
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwift
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwiftSwift & ReactiveX – Asynchronous Event-Based Funsies with RxSwift
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwift
 
Découvrir dtrace en ligne de commande.
Découvrir dtrace en ligne de commande.Découvrir dtrace en ligne de commande.
Découvrir dtrace en ligne de commande.
 
Reacting with ReactiveUI
Reacting with ReactiveUIReacting with ReactiveUI
Reacting with ReactiveUI
 
Reactive Programming with RxSwift
Reactive Programming with RxSwiftReactive Programming with RxSwift
Reactive Programming with RxSwift
 
Introduction to RxJS
Introduction to RxJSIntroduction to RxJS
Introduction to RxJS
 

Similar to Automated UI testing for iOS apps using KIF framework and Swift

Pushing Datatothe Browserwith Comet Ajax W
Pushing Datatothe Browserwith Comet Ajax WPushing Datatothe Browserwith Comet Ajax W
Pushing Datatothe Browserwith Comet Ajax Wrajivmordani
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09Daniel Bryant
 
Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Paco de la Cruz
 
Taming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, MacoscopeTaming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, MacoscopeMacoscope
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaRick Warren
 
Advanced #6 clean architecture
Advanced #6  clean architectureAdvanced #6  clean architecture
Advanced #6 clean architectureVitali Pekelis
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedToru Wonyoung Choi
 
Spring 3: What's New
Spring 3: What's NewSpring 3: What's New
Spring 3: What's NewTed Pennings
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade ServerlessKatyShimizu
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade ServerlessKatyShimizu
 
Html5 : stockage local & synchronisation
Html5 : stockage local & synchronisationHtml5 : stockage local & synchronisation
Html5 : stockage local & synchronisationgoldoraf
 
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Codemotion
 
Devfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdfDevfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdfKAI CHU CHUNG
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with SpringJoshua Long
 
Behavioral pattern 4
Behavioral pattern 4Behavioral pattern 4
Behavioral pattern 4Naga Muruga
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemAndres Almiray
 
JEE on DC/OS - MesosCon Europe
JEE on DC/OS - MesosCon EuropeJEE on DC/OS - MesosCon Europe
JEE on DC/OS - MesosCon EuropeQAware GmbH
 

Similar to Automated UI testing for iOS apps using KIF framework and Swift (20)

Backendless apps
Backendless appsBackendless apps
Backendless apps
 
Pushing Datatothe Browserwith Comet Ajax W
Pushing Datatothe Browserwith Comet Ajax WPushing Datatothe Browserwith Comet Ajax W
Pushing Datatothe Browserwith Comet Ajax W
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
 
Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)
 
Taming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, MacoscopeTaming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, Macoscope
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
Advanced #6 clean architecture
Advanced #6  clean architectureAdvanced #6  clean architecture
Advanced #6 clean architecture
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO Extended
 
Spring 3: What's New
Spring 3: What's NewSpring 3: What's New
Spring 3: What's New
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
 
Html5 : stockage local & synchronisation
Html5 : stockage local & synchronisationHtml5 : stockage local & synchronisation
Html5 : stockage local & synchronisation
 
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...
 
Devfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdfDevfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdf
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
 
Behavioral pattern 4
Behavioral pattern 4Behavioral pattern 4
Behavioral pattern 4
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
 
JEE on DC/OS - MesosCon Europe
JEE on DC/OS - MesosCon EuropeJEE on DC/OS - MesosCon Europe
JEE on DC/OS - MesosCon Europe
 
JEE on DC/OS
JEE on DC/OSJEE on DC/OS
JEE on DC/OS
 

More from Jurgis Kirsakmens

Using analytics in iOS apps - #uikonf2016 #unconference
Using analytics in iOS apps - #uikonf2016 #unconferenceUsing analytics in iOS apps - #uikonf2016 #unconference
Using analytics in iOS apps - #uikonf2016 #unconferenceJurgis Kirsakmens
 
Analytics for iOS apps (crash/diagnostic/usage/sales)
Analytics for iOS apps (crash/diagnostic/usage/sales) Analytics for iOS apps (crash/diagnostic/usage/sales)
Analytics for iOS apps (crash/diagnostic/usage/sales) Jurgis Kirsakmens
 
How much does it cost to build a mobile app?
How much does it cost to build a mobile app?How much does it cost to build a mobile app?
How much does it cost to build a mobile app?Jurgis Kirsakmens
 
Mobilās aplikācijas un uzņēmumu komunikācija
Mobilās aplikācijas un uzņēmumu komunikācijaMobilās aplikācijas un uzņēmumu komunikācija
Mobilās aplikācijas un uzņēmumu komunikācijaJurgis Kirsakmens
 
Future:apps&mobile - mobile landscape and development platforms
Future:apps&mobile - mobile landscape and development platformsFuture:apps&mobile - mobile landscape and development platforms
Future:apps&mobile - mobile landscape and development platformsJurgis Kirsakmens
 
Netiquette- short introduction
Netiquette- short introductionNetiquette- short introduction
Netiquette- short introductionJurgis Kirsakmens
 

More from Jurgis Kirsakmens (7)

Using analytics in iOS apps - #uikonf2016 #unconference
Using analytics in iOS apps - #uikonf2016 #unconferenceUsing analytics in iOS apps - #uikonf2016 #unconference
Using analytics in iOS apps - #uikonf2016 #unconference
 
Analytics for iOS apps (crash/diagnostic/usage/sales)
Analytics for iOS apps (crash/diagnostic/usage/sales) Analytics for iOS apps (crash/diagnostic/usage/sales)
Analytics for iOS apps (crash/diagnostic/usage/sales)
 
Take a Break
Take a BreakTake a Break
Take a Break
 
How much does it cost to build a mobile app?
How much does it cost to build a mobile app?How much does it cost to build a mobile app?
How much does it cost to build a mobile app?
 
Mobilās aplikācijas un uzņēmumu komunikācija
Mobilās aplikācijas un uzņēmumu komunikācijaMobilās aplikācijas un uzņēmumu komunikācija
Mobilās aplikācijas un uzņēmumu komunikācija
 
Future:apps&mobile - mobile landscape and development platforms
Future:apps&mobile - mobile landscape and development platformsFuture:apps&mobile - mobile landscape and development platforms
Future:apps&mobile - mobile landscape and development platforms
 
Netiquette- short introduction
Netiquette- short introductionNetiquette- short introduction
Netiquette- short introduction
 

Recently uploaded

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 

Recently uploaded (20)

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 

Automated UI testing for iOS apps using KIF framework and Swift

  • 2. CASE FOR UI TESTING INTEGRATION
 NAVIGATION FLOW
 DATA FLOW
 USER EXPERIENCE
 ACCESSIBILITY
 REFACTORINGS / REGRESSIONS
  • 3. UI TESTING IS HARD 
 AND TIME CONSUMING UNLESS
 AUTOMATED 
 EASYTO MAINTAIN
 FAST
  • 4.
  • 5. NATIVE SUPPORT 
 FOR UI TESTING UI AUTOMATION (JavaScript)
 XCUI (Swift/Objective C)
 BASED ON UIAcessibility PROTOCOL
  • 6. KIF
 Keep It Functional - An iOS Functional Testing Framework https://github.com/kif-framework/KIF
 UICONF 2016 TALK BY ELLEN SHAPIRO
 https://youtu.be/hYCUy-9yq_M
  • 7. OBJECTIVE C - KIFTestCase RUNS IN APP TARGET
 beforeAll, beforeEach, afterAll, afterEach
 KIFUITestActor - USER ACTIONS
 KIFSystemTestActor - SYSTEM/DEVICE ACTIONS SWIFT - XCTestCase ADD SIMPLE EXTENSION TO ACCESS KIFUITestActor AND KIFSystemTestActor
  • 9. EXTENSIONS FOR READIBILITY extension KIFUITestActor { @discardableResult func waitForButton(_ label: String) -> UIView! { let button = self.waitForTappableView(withAccessibilityLabel: label, traits: UIAccessibilityTraitButton) return button } func tapButton(_ accessibilityLabel: String, value: String) { let button = waitForButton(accessibilityLabel, value: value) button?.tap() } } RESULT tester().tapButton(“Login”) // or even better – tester().tapLoginButton()
  • 10. PROTOCOLTO ACCESS APP DATA public protocol UsesCoreDataDatabase { func dbContext() -> NSManagedObjectContext func isDbEmpty(_ context: NSManagedObjectContext) -> Bool func deleteDbData(_ context: NSManagedObjectContext) } public extension UsesCoreDataDatabase { func dbContext() -> NSManagedObjectContext { let appDelegate: YourAppDelegate = UIApplication.shared.delegate as! YourAppDelegate let context = appDelegate.value(forKey: "context") as! NSManagedObjectContext XCTAssertNotNil(context) return context! } func isDbEmpty(_ context: NSManagedObjectContext) -> Bool { // access model objects from context let count = …. return (count == 0) } func deleteDbData(_ context: NSManagedObjectContext) { // Delete data }
  • 11. CUSTOM TEST CASES class MyTestCaseWithEmptyDatabase: KIFTestCase, UsesCoreDataDatabase { override func beforeEach() { let context = dbContext() if ! sDbEmpty(context) { let name = MyAppServices.deviceModel() if name == "iPhone Simulator" { deleteDbData(context) } else { } // Are you sure want to delete data from device? } } } class MyTestCaseWithWizardFilled: MyTestCaseWithEmptyDatabase { var rentAmount = “100”; var unitName= “M10”; var tenantName = “Anna" override func beforeEach() { super.beforeEach() let context = dbContext() MyWizardController.saveFromWizard(in: context, address: unitName, tenant: tenantName amount: rentAmount) } } class MyTestCaseWithFixturesLoaded : MyTestCaseWithEmptyDatabase { // load fixture data in database }
  • 12. DRY, READABLE TESTS class PaymentTests: MyTestCaseWithWizardFilled { func testAddPayment_fromUnitDashboard() { // given - tenantName, unitName, today are defined as MyTestCaseWithWizardFilled class variables let amount = “5.1”; let paymentAmount = “$5.10” tester().tapPropertiesTabButton() tester().tapUnit(unitName, tenant: tenantName) tester().waitForTenantBalanceScreen(tenantName, currentBalance: "$0.00") tester().waitForLastPaymentLine("No rent payments received", amount: “") // even this should be replaced by waitForNoLastPaymentLine // when tester().tapAddPaymentButton() tester().enterOnKeyboard(amount) tester().tapSaveButton() // then tester().waitForTenantBalanceScreen(tenantName, currentBalance: paymentAmount) tester().waitForLastRentPaymentLine(today, amount: paymentAmount) } } … public extension KIFUITestActor { /// Returns last payment line in rental unit dashboard @discardableResult func waitForLastPaymentLine(_ date: String, amount: String) -> UIView! { let view = waitForView("Last rent payment", value: "(date), (amount)”) // Accessibility label & accessibility value return view } }
  • 14. MAKE UI TESTS FASTER class MyTestCaseWithEmptyDatabase: KIFTestCase, UsesCoreDataDatabase { override func beforeAll() { UIApplication.shared.keyWindow!.layer.speed = 100; // faster animations } }
  • 15. GOTCHAS & HINTS OCCASIONALLY CAN FAIL WITHOUT A GOOD REASON
 ¯_( )_/¯
 BEWARE OF UITableViewCells
 ADD EVERYTHING AS SUBVIEWTO .contentView
 SAVE SCREENSHOTS ON TEST FAILURE
 SET ENVVARIABLE WITH FOLDER LOCATION- KIF_SCREENSHOTS= …
 
 AFTER FAILING TEST IN MODAL VIEW ALL OTHER TEST RESULTS = USELESS
 do { try tester().trySomething(); // then test } catch {}
  • 16. ACCESSIBILITY https://youtu.be/no12EfZUSQo “You have no clue about your app accessibility until you write app UI tests that rely on accessibility” / me to myself /
  • 17.
  • 18. UIAccessibility PROTOCOL UIAccessibilityElement CLASS UIAccessibilityContainer PROTOCOL UIAccessibilityTraits
 
 BUNDLED FREE WHEN USING UIKit,JUST SET 
 accessibilityLabel, accessibilityValue, accessibilityHint 
 IN IB AND/OR CODE