SlideShare a Scribd company logo
1 of 30
TheMobile DevOps Company
Ville-VeikkoHelppi
HeadofDemandGeneration
ville-veikko.helppi@bitbar.com
GettingStarted with
XCTest andXCUITest
for iOS App Testing
WEBINAR
XCTest&XCUITest
• The State of The Art in iOS App Testing
– Frameworks, Tools & Methods
• The Basics of XCTest & XCUITest –
And How to Get Started
• Alternative iOS Test Automation
Frameworks – Pros and Cons of Each
• Demonstration
• Q&A
Agenda
http://bitbar.com/testing/
More informationabout test
automation frameworks for iOS:
bitbar.com/testing/
PublicCloud
• Device ‘Cloud’ built for internal testing use
• Enterprise-grade testing infrastructure hosted by the
customer
• Usually sits behind customer firewall and connects to
preproduction environments
• Private Device Cloud
• Reserved and Dedicated devices
• Hosted and Fully Managed by Bitbar
• Devices chosen by and reserved exclusively for
customer
• Also known as Testdroid Cloud
• On-demand devices (multi-tenant)
• Mobile App testing on over 1000+ real Android and
iOS devices hosted by Bitbar
Private Cloud
PRODUCT
UPDATE:
XCTest & XCUITest
Support Available On-Premise
XCTest/XCUITest Supported
• Integral framework in Xcode
• Not a new framework: Xcode 5
introduced the first version of XCTest
• Incrementally new
capabilities/features:
o Xcode 6 – performance measurement
o Xcode 7 – UI testing (XCUITest)
• Works with both Swift and Objective-C
XCTest &
XCUITest
What isXCTest/XCUITest?
• Easy to learn, no additional installations or
components required (to Xcode)
• Native iOS language support
• Xcode Test Recorder (for XCUITest)
• Integration with Xcode Server (continuous
integration) and Bots
• Faster than many other popular functional
(and cross-platform) test frameworks
• Works with both Swift and Objective-C
XCTest
Pros of XCTest
• No cross-platform support
• Limited programming language
support
• Selectors may seem complex
• Requires (always) a separate
test target
• Signing can be ‘tricky’
• Sometimes… well, flaky
XCTest
Cons of XCTest
The Status of iOS Test Automation Frameworks
• If you running a test script
built for prior Xcode
versions, all uia_* calls will
raise an error with the latest
Xcode
• When upgrading to Xcode 8
all your existing
UIAutomation scripts will fail
Deprecated
UI Automation
MigratingUIA-> XCTest?
The Basics of
XCTest & XCUITest
and
How to Get Started
New Ebook Available!
Download This Guide
• A test method is an instance
method of a test class that
begins with prefix “test”
• Tests are simply classes and
methods and e.g. @property
and helper methods can be
added to the class
XCTest &
XCUITest
Getting Started
-(void)testExample {
XCTAssert(...);
XCTAssertTrue(...);
XCTAssertFalse(...);
}
• Tests are grouped into
classes that are subclass
from XCTestCase
XCTest &
XCUITest
WritingTest Methods
class DemoTest: XCTestCase {
- (void)testExample {
// This is an example of a functional test case.
// Use XCTAssert and related functions
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
}
XCTest &
XCUITest
XCTestCase Example - Swift
import UIKit
import XCTest
@testable import LocalizationDemo
class LocalizationDemoTests: XCTestCase {
override func setUp() {
super.setUp()
}
override func tearDown() {
super.tearDown()
}
func testMyModel() {
// Example of a functional test case.
var model = MyModel(name: "first", surname: "last");
XCTAssertEqual(model.a, "first");
XCTAssertNotEqual(model.b, "first");
}
func testIfLocalizationWorks() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
}
• A performance test takes a block of code
(that is measured) and runs it ten times,
collecting the average execution time and
the standard deviation for the runs
XCTest &
XCUITest
WritingPerformance Tests
- (void) testAdditionPerformance {
[self measureBlock:^{
// set the initial state
[calcViewController press:[calcView viewWithTag: 6]];
// iterate for 100000 cycles of adding 2
for (int i=0; i<100000; i++) {
[calcViewController press:[calcView
viewWithTag:13]];
[calcViewController press:[calcView viewWithTag:
2]];
[calcViewController press:[calcView
viewWithTag:12]];
}
}];
}
XCUIApplication
• The XCUIApplication is basically a
proxy for an app that can be launched
and terminated
• User can tell the application to run in
testing mode by defining app as a
“Target Application” in Xcode target
settings
Code Syntax (XCUITest)
// Objective-C
XCUIApplication *app = [[XCUIApplication alloc] init];
// Swift
let app = XCUIApplication()
XCUIElement
• XCUIElement is the
actual UI element in
an iOS application
• XCUIElement
provides all the basics
symbols and
functions for UI
element interactions
• Gestures with XCTest
include clicking UI
elements (normal,
double, pressing),
interacting with the
screen (swipe, pinch,
zoom, rotate etc.)
Code Syntax (XCUITest)
// Click-based functions
tap()
doubleTap()
twoFingerTap()
tap(withNumberOfTaps: UInt, numberOfTouches: UInt)
press(forDuration: TimeInterval)
press(forDuration: TimeInterval, thenDragTo: XCUIElement)
// Generic UI interactions
swipeLeft()
swipeRight()
swipeUp()
swipeDown()
pinch(withScale: CGFloat, velocity: CGFloat)
rotate(CGFloat, withVelocity: CGFloat)
XCUIElement
• XCUIElement is
constructed using
the actual user
interface elements
on the screen
• XCUIElement
inherits from
NSObject
• In order to perform
any interaction (tap
on this example) on
a UI element the UI
interactions are
available for use.
Code Syntax (XCUITest)
XCUIApplication *app = [[XCUIApplication alloc] init];
XCUIElement *masterNavigationBar =
app.navigationBars[@"Master"];
XCUIElement *editButton =
masterNavigationBar.buttons[@"Edit"];
// Objective-C
[masterNavigationBar.staticTexts[@"Master"] tap];
[editButton tap];
• Two ways to create IPA for
test automation
1. Working with Xcode
2. Working from Command Line
• Test package can be built as
APP file and zipped for
cloud execution
Preparing IPA and
Test Package for
Simultaneous
Device Runs
Methods to Create IPAand Test Package for
Simultaneous Tests
• By archiving any build package will
be compatible with an iOS device
• When your build is done and
archiving has finished, select the
build from Archive list and click
“Export…”
Working on
Xcode to Create
IPA for Testing
1. Archive Your Build
• When the following window is
shown, simply select “Save for Ad
Hoc Deployment” and click Next.
Working on
Xcode to Create
IPA for Testing
2. Select The Right Method
• Use the same identify what you use in
build settings for code signing.
• If your project and Xcode is properly
configured you should see the following
type of dialog proposing the first usable
identifier:
Working on
Xcode to Create
IPA for Testing
3. Identify Yourself(andYourBuild)
• It’s almost always recommended to include
all possible device support for your app.
• If you want to reduce the size of your IPA
you can shrink it by selecting to support only
certain devices and OS versions
Working on
Xcode to Create
IPA for Testing
4. Select OS and Devices
• This can be done Product -> Build
for -> Testing menu:
Working on
Command Line to
Create IPA for
Testing
1. Select toBuildfor Testing
• Next, select your project in Project
Navigator and right click to “Show it in
Finder”:
Working on
Command Line to
Create IPA for
Testing
2. Locate App Fileon HD
• After Finder dialog has been opened
and files are shown, just highlight the
.app file and right-click to see copying
option, as follows:
Working on
Command Line to
Create IPA for
Testing
3. Copy App FileProperly
• After Finder dialog has been opened
and files are shown, just highlight the
.app file and right-click to see copying
option, as follows:
Working on
Command Line to
Create IPA for
Testing
4. Create IPA from CMD
$ mkdir /tmp/Payload
$ cd /tmp/Payload
$ cp -r /User/Path/Debug-iphoneos/LocalizationDemo.app .
$ cd ..
$ zip --symlinks -qr "LocalizationDemo.ipa" Payload
$ ls -lrt LocalizationDemo.ipa
-rw-r--r-- 1 username staff 0 Dec 16 12:42 LocalizationDemo.ipa
• If building for iPhone 5 or iPhone 5C (with
ARMv7 32-bit processor) devices, additional
step is needed before creating the build.
• Starting from Xcode 7, armv7s is no more part
of the default $(ARCHS_STANDARD) and so
should be added as a target build architecture
Creating an IPA
for iOS App
Testing
Good To Know!
Quick
XCTest/XCUITest
Comparison
Ebooks Available for…
XCTest/
XCUITest
Calabash Appium
Top 3 iOS Test Automation Frameworks
XCTEST/XCUITEST APPIUM CALABASH
CROSS-PLATFORM No Yes Yes
IOS Yes Yes Yes
MOBILE WEB Yes Yes No
LANGUAGE Obj-C/Swift Almost any Ruby
TOOL FOR TEST
CREATION
Xcode Appium.app CLI
(Human-Readable syntax)
COMMUNITY Apple Community Community
Demo
Xcode 6 / 7 / 8
Summary– Q&A
Moreinformationaboutmobileapptesting,
mobilemonitoringandmobiledevopsat
bitbar.com

More Related Content

What's hot

Cross-Browser-Testing with Protractor & Browserstack
Cross-Browser-Testing with Protractor & BrowserstackCross-Browser-Testing with Protractor & Browserstack
Cross-Browser-Testing with Protractor & BrowserstackLeo Lindhorst
 
Postman Introduction
Postman IntroductionPostman Introduction
Postman IntroductionRahul Agarwal
 
Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUIBongwon Lee
 
Android & iOS Automation Using Appium
Android & iOS Automation Using AppiumAndroid & iOS Automation Using Appium
Android & iOS Automation Using AppiumMindfire Solutions
 
Appium basics
Appium basicsAppium basics
Appium basicsSyam Sasi
 
Mobile application testing
Mobile application testingMobile application testing
Mobile application testingSoftheme
 
Ui testing in xcode
Ui testing in xcodeUi testing in xcode
Ui testing in xcodeallanh0526
 
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil TayarCypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil TayarApplitools
 
Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?Shivam Bharadwaj
 
Introduction to Ionic framework
Introduction to Ionic frameworkIntroduction to Ionic framework
Introduction to Ionic frameworkShyjal Raazi
 
User Interface Testing. What is UI Testing and Why it is so important?
User Interface Testing. What is UI Testing and Why it is so important?User Interface Testing. What is UI Testing and Why it is so important?
User Interface Testing. What is UI Testing and Why it is so important?Maveryx
 
Espresso testing
Espresso testingEspresso testing
Espresso testingvodqancr
 
Postman: An Introduction for Developers
Postman: An Introduction for DevelopersPostman: An Introduction for Developers
Postman: An Introduction for DevelopersPostman
 

What's hot (20)

Cross-Browser-Testing with Protractor & Browserstack
Cross-Browser-Testing with Protractor & BrowserstackCross-Browser-Testing with Protractor & Browserstack
Cross-Browser-Testing with Protractor & Browserstack
 
iOS platform
iOS platformiOS platform
iOS platform
 
Browser_Stack_Intro
Browser_Stack_IntroBrowser_Stack_Intro
Browser_Stack_Intro
 
End to end test automation with cypress
End to end test automation with cypressEnd to end test automation with cypress
End to end test automation with cypress
 
Postman Introduction
Postman IntroductionPostman Introduction
Postman Introduction
 
Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUI
 
Android & iOS Automation Using Appium
Android & iOS Automation Using AppiumAndroid & iOS Automation Using Appium
Android & iOS Automation Using Appium
 
Appium basics
Appium basicsAppium basics
Appium basics
 
Appium.pptx
Appium.pptxAppium.pptx
Appium.pptx
 
Mobile application testing
Mobile application testingMobile application testing
Mobile application testing
 
Belajar Postman test runner
Belajar Postman test runnerBelajar Postman test runner
Belajar Postman test runner
 
Ui testing in xcode
Ui testing in xcodeUi testing in xcode
Ui testing in xcode
 
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil TayarCypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
 
Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?
 
Introduction to Ionic framework
Introduction to Ionic frameworkIntroduction to Ionic framework
Introduction to Ionic framework
 
API Testing
API TestingAPI Testing
API Testing
 
User Interface Testing. What is UI Testing and Why it is so important?
User Interface Testing. What is UI Testing and Why it is so important?User Interface Testing. What is UI Testing and Why it is so important?
User Interface Testing. What is UI Testing and Why it is so important?
 
Api testing
Api testingApi testing
Api testing
 
Espresso testing
Espresso testingEspresso testing
Espresso testing
 
Postman: An Introduction for Developers
Postman: An Introduction for DevelopersPostman: An Introduction for Developers
Postman: An Introduction for Developers
 

Similar to Getting Started with XCTest and XCUITest for iOS App Testing

Xamarin UI Test And Xamarin Test Cloud
Xamarin UI Test And Xamarin Test CloudXamarin UI Test And Xamarin Test Cloud
Xamarin UI Test And Xamarin Test CloudEmanuel Amiguinho
 
XCUITest for iOS App Testing and how to test with Xcode
XCUITest for iOS App Testing and how to test with XcodeXCUITest for iOS App Testing and how to test with Xcode
XCUITest for iOS App Testing and how to test with XcodepCloudy
 
Automating Mobile Applications
Automating Mobile ApplicationsAutomating Mobile Applications
Automating Mobile ApplicationsApril Luk
 
JBCN_Testing_With_Containers
JBCN_Testing_With_ContainersJBCN_Testing_With_Containers
JBCN_Testing_With_ContainersGrace Jansen
 
iOS Application Security
iOS Application SecurityiOS Application Security
iOS Application SecurityEgor Tolstoy
 
Mobile Testing Challenges Lighting Talk with www.softtest.ie
Mobile Testing Challenges Lighting Talk with www.softtest.ieMobile Testing Challenges Lighting Talk with www.softtest.ie
Mobile Testing Challenges Lighting Talk with www.softtest.ieDavid O'Dowd
 
JLove - Replicating production on your laptop using the magic of containers
JLove - Replicating production on your laptop using the magic of containersJLove - Replicating production on your laptop using the magic of containers
JLove - Replicating production on your laptop using the magic of containersGrace Jansen
 
2012 java one-con3648
2012 java one-con36482012 java one-con3648
2012 java one-con3648Eing Ong
 
Advanced Coded UI Testing
Advanced Coded UI TestingAdvanced Coded UI Testing
Advanced Coded UI TestingShai Raiten
 
Modeveast Appcelerator Presentation
Modeveast Appcelerator PresentationModeveast Appcelerator Presentation
Modeveast Appcelerator PresentationAaron Saunders
 
Fashionable XCUITest for iOS Apps by Shashikant Jagtap
Fashionable XCUITest for iOS Apps by Shashikant JagtapFashionable XCUITest for iOS Apps by Shashikant Jagtap
Fashionable XCUITest for iOS Apps by Shashikant JagtapSauce Labs
 
Hudson
HudsonHudson
Hudson8x8
 
Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Kevin Munc
 
SauceCon19: Fashionable XCUITest for iOS App
SauceCon19: Fashionable XCUITest for iOS App SauceCon19: Fashionable XCUITest for iOS App
SauceCon19: Fashionable XCUITest for iOS App Shashikant Jagtap
 
Run somke test on AWS DeviceFarm
Run somke test on AWS DeviceFarmRun somke test on AWS DeviceFarm
Run somke test on AWS DeviceFarmNaoki AINOYA
 

Similar to Getting Started with XCTest and XCUITest for iOS App Testing (20)

Xamarin UI Test And Xamarin Test Cloud
Xamarin UI Test And Xamarin Test CloudXamarin UI Test And Xamarin Test Cloud
Xamarin UI Test And Xamarin Test Cloud
 
XCUITest for iOS App Testing and how to test with Xcode
XCUITest for iOS App Testing and how to test with XcodeXCUITest for iOS App Testing and how to test with Xcode
XCUITest for iOS App Testing and how to test with Xcode
 
Calabash for iPhone apps
Calabash for iPhone appsCalabash for iPhone apps
Calabash for iPhone apps
 
Automating Mobile Applications
Automating Mobile ApplicationsAutomating Mobile Applications
Automating Mobile Applications
 
JBCN_Testing_With_Containers
JBCN_Testing_With_ContainersJBCN_Testing_With_Containers
JBCN_Testing_With_Containers
 
iOS Application Security
iOS Application SecurityiOS Application Security
iOS Application Security
 
Mobile Testing Challenges Lighting Talk with www.softtest.ie
Mobile Testing Challenges Lighting Talk with www.softtest.ieMobile Testing Challenges Lighting Talk with www.softtest.ie
Mobile Testing Challenges Lighting Talk with www.softtest.ie
 
JLove - Replicating production on your laptop using the magic of containers
JLove - Replicating production on your laptop using the magic of containersJLove - Replicating production on your laptop using the magic of containers
JLove - Replicating production on your laptop using the magic of containers
 
iOS Application Exploitation
iOS Application ExploitationiOS Application Exploitation
iOS Application Exploitation
 
IOS ecosystem
IOS ecosystemIOS ecosystem
IOS ecosystem
 
2012 java one-con3648
2012 java one-con36482012 java one-con3648
2012 java one-con3648
 
Advanced Coded UI Testing
Advanced Coded UI TestingAdvanced Coded UI Testing
Advanced Coded UI Testing
 
Modeveast Appcelerator Presentation
Modeveast Appcelerator PresentationModeveast Appcelerator Presentation
Modeveast Appcelerator Presentation
 
Fashionable XCUITest for iOS Apps by Shashikant Jagtap
Fashionable XCUITest for iOS Apps by Shashikant JagtapFashionable XCUITest for iOS Apps by Shashikant Jagtap
Fashionable XCUITest for iOS Apps by Shashikant Jagtap
 
Hudson
HudsonHudson
Hudson
 
Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013
 
SauceCon19: Fashionable XCUITest for iOS App
SauceCon19: Fashionable XCUITest for iOS App SauceCon19: Fashionable XCUITest for iOS App
SauceCon19: Fashionable XCUITest for iOS App
 
Run somke test on AWS DeviceFarm
Run somke test on AWS DeviceFarmRun somke test on AWS DeviceFarm
Run somke test on AWS DeviceFarm
 
tut0000021-hevery
tut0000021-heverytut0000021-hevery
tut0000021-hevery
 
tut0000021-hevery
tut0000021-heverytut0000021-hevery
tut0000021-hevery
 

More from Bitbar

The Best of Both Worlds - Combining Performance and Functional Mobile App Tes...
The Best of Both Worlds - Combining Performance and Functional Mobile App Tes...The Best of Both Worlds - Combining Performance and Functional Mobile App Tes...
The Best of Both Worlds - Combining Performance and Functional Mobile App Tes...Bitbar
 
Mobile performance metrics and performance monitoring meetup 2017 05 10
Mobile performance metrics and performance monitoring meetup 2017 05 10Mobile performance metrics and performance monitoring meetup 2017 05 10
Mobile performance metrics and performance monitoring meetup 2017 05 10Bitbar
 
Exercising and Scaling Up Mobile DevOps in the Enterprise
Exercising and Scaling Up Mobile DevOps in the EnterpriseExercising and Scaling Up Mobile DevOps in the Enterprise
Exercising and Scaling Up Mobile DevOps in the EnterpriseBitbar
 
Hassle-Free Continuous Integration with Real Device Testing
Hassle-Free Continuous Integration with Real Device TestingHassle-Free Continuous Integration with Real Device Testing
Hassle-Free Continuous Integration with Real Device TestingBitbar
 
Best Practices for DevOps in Mobile App Testing
Best Practices for DevOps in Mobile App TestingBest Practices for DevOps in Mobile App Testing
Best Practices for DevOps in Mobile App TestingBitbar
 
Ensure Your Mobile Channels Generate Revenue on Holiday Peak Days
Ensure Your Mobile Channels Generate Revenue on Holiday Peak DaysEnsure Your Mobile Channels Generate Revenue on Holiday Peak Days
Ensure Your Mobile Channels Generate Revenue on Holiday Peak DaysBitbar
 
How to Reliably Measure and Optimize Graphics Performance of Your Android Games
How to Reliably Measure and Optimize Graphics Performance of Your Android GamesHow to Reliably Measure and Optimize Graphics Performance of Your Android Games
How to Reliably Measure and Optimize Graphics Performance of Your Android GamesBitbar
 
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on Webinar
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on WebinarParallel Test Runs with Appium on Real Mobile Devices – Hands-on Webinar
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on WebinarBitbar
 
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)Bitbar
 
The Powerful and Comprehensive API for Mobile App Development and Testing
The Powerful and Comprehensive API for Mobile App Development and TestingThe Powerful and Comprehensive API for Mobile App Development and Testing
The Powerful and Comprehensive API for Mobile App Development and TestingBitbar
 
Which One Works You The Best: In-House or Cloud-Based Development Environment
Which One Works You The Best: In-House or Cloud-Based Development EnvironmentWhich One Works You The Best: In-House or Cloud-Based Development Environment
Which One Works You The Best: In-House or Cloud-Based Development EnvironmentBitbar
 
Best Practices in Mobile Game Testing
Best Practices in Mobile Game TestingBest Practices in Mobile Game Testing
Best Practices in Mobile Game TestingBitbar
 
Build a Large Scale In-House Test Lab for Mobile Apps
Build a Large Scale In-House Test Lab for Mobile AppsBuild a Large Scale In-House Test Lab for Mobile Apps
Build a Large Scale In-House Test Lab for Mobile AppsBitbar
 
The Status of Android Hardware and Software - From App Developer's Point of View
The Status of Android Hardware and Software - From App Developer's Point of ViewThe Status of Android Hardware and Software - From App Developer's Point of View
The Status of Android Hardware and Software - From App Developer's Point of ViewBitbar
 
Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Bitbar
 
Testing Your Android and iOS Apps with Appium in Testdroid Cloud
Testing Your Android and iOS Apps with Appium in Testdroid CloudTesting Your Android and iOS Apps with Appium in Testdroid Cloud
Testing Your Android and iOS Apps with Appium in Testdroid CloudBitbar
 
How to Leverage Appium in Your Mobile App Testing
How to Leverage Appium in Your Mobile App TestingHow to Leverage Appium in Your Mobile App Testing
How to Leverage Appium in Your Mobile App TestingBitbar
 
How to Test Security and Vulnerability of Your Android and iOS Apps
How to Test Security and Vulnerability of Your Android and iOS AppsHow to Test Security and Vulnerability of Your Android and iOS Apps
How to Test Security and Vulnerability of Your Android and iOS AppsBitbar
 
Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Bitbar
 
Maximize the Benefits from Your Test Automation Investment
Maximize the Benefits from Your Test Automation InvestmentMaximize the Benefits from Your Test Automation Investment
Maximize the Benefits from Your Test Automation InvestmentBitbar
 

More from Bitbar (20)

The Best of Both Worlds - Combining Performance and Functional Mobile App Tes...
The Best of Both Worlds - Combining Performance and Functional Mobile App Tes...The Best of Both Worlds - Combining Performance and Functional Mobile App Tes...
The Best of Both Worlds - Combining Performance and Functional Mobile App Tes...
 
Mobile performance metrics and performance monitoring meetup 2017 05 10
Mobile performance metrics and performance monitoring meetup 2017 05 10Mobile performance metrics and performance monitoring meetup 2017 05 10
Mobile performance metrics and performance monitoring meetup 2017 05 10
 
Exercising and Scaling Up Mobile DevOps in the Enterprise
Exercising and Scaling Up Mobile DevOps in the EnterpriseExercising and Scaling Up Mobile DevOps in the Enterprise
Exercising and Scaling Up Mobile DevOps in the Enterprise
 
Hassle-Free Continuous Integration with Real Device Testing
Hassle-Free Continuous Integration with Real Device TestingHassle-Free Continuous Integration with Real Device Testing
Hassle-Free Continuous Integration with Real Device Testing
 
Best Practices for DevOps in Mobile App Testing
Best Practices for DevOps in Mobile App TestingBest Practices for DevOps in Mobile App Testing
Best Practices for DevOps in Mobile App Testing
 
Ensure Your Mobile Channels Generate Revenue on Holiday Peak Days
Ensure Your Mobile Channels Generate Revenue on Holiday Peak DaysEnsure Your Mobile Channels Generate Revenue on Holiday Peak Days
Ensure Your Mobile Channels Generate Revenue on Holiday Peak Days
 
How to Reliably Measure and Optimize Graphics Performance of Your Android Games
How to Reliably Measure and Optimize Graphics Performance of Your Android GamesHow to Reliably Measure and Optimize Graphics Performance of Your Android Games
How to Reliably Measure and Optimize Graphics Performance of Your Android Games
 
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on Webinar
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on WebinarParallel Test Runs with Appium on Real Mobile Devices – Hands-on Webinar
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on Webinar
 
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
 
The Powerful and Comprehensive API for Mobile App Development and Testing
The Powerful and Comprehensive API for Mobile App Development and TestingThe Powerful and Comprehensive API for Mobile App Development and Testing
The Powerful and Comprehensive API for Mobile App Development and Testing
 
Which One Works You The Best: In-House or Cloud-Based Development Environment
Which One Works You The Best: In-House or Cloud-Based Development EnvironmentWhich One Works You The Best: In-House or Cloud-Based Development Environment
Which One Works You The Best: In-House or Cloud-Based Development Environment
 
Best Practices in Mobile Game Testing
Best Practices in Mobile Game TestingBest Practices in Mobile Game Testing
Best Practices in Mobile Game Testing
 
Build a Large Scale In-House Test Lab for Mobile Apps
Build a Large Scale In-House Test Lab for Mobile AppsBuild a Large Scale In-House Test Lab for Mobile Apps
Build a Large Scale In-House Test Lab for Mobile Apps
 
The Status of Android Hardware and Software - From App Developer's Point of View
The Status of Android Hardware and Software - From App Developer's Point of ViewThe Status of Android Hardware and Software - From App Developer's Point of View
The Status of Android Hardware and Software - From App Developer's Point of View
 
Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?
 
Testing Your Android and iOS Apps with Appium in Testdroid Cloud
Testing Your Android and iOS Apps with Appium in Testdroid CloudTesting Your Android and iOS Apps with Appium in Testdroid Cloud
Testing Your Android and iOS Apps with Appium in Testdroid Cloud
 
How to Leverage Appium in Your Mobile App Testing
How to Leverage Appium in Your Mobile App TestingHow to Leverage Appium in Your Mobile App Testing
How to Leverage Appium in Your Mobile App Testing
 
How to Test Security and Vulnerability of Your Android and iOS Apps
How to Test Security and Vulnerability of Your Android and iOS AppsHow to Test Security and Vulnerability of Your Android and iOS Apps
How to Test Security and Vulnerability of Your Android and iOS Apps
 
Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?
 
Maximize the Benefits from Your Test Automation Investment
Maximize the Benefits from Your Test Automation InvestmentMaximize the Benefits from Your Test Automation Investment
Maximize the Benefits from Your Test Automation Investment
 

Recently uploaded

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Getting Started with XCTest and XCUITest for iOS App Testing

  • 2. XCTest&XCUITest • The State of The Art in iOS App Testing – Frameworks, Tools & Methods • The Basics of XCTest & XCUITest – And How to Get Started • Alternative iOS Test Automation Frameworks – Pros and Cons of Each • Demonstration • Q&A Agenda http://bitbar.com/testing/ More informationabout test automation frameworks for iOS: bitbar.com/testing/
  • 3. PublicCloud • Device ‘Cloud’ built for internal testing use • Enterprise-grade testing infrastructure hosted by the customer • Usually sits behind customer firewall and connects to preproduction environments • Private Device Cloud • Reserved and Dedicated devices • Hosted and Fully Managed by Bitbar • Devices chosen by and reserved exclusively for customer • Also known as Testdroid Cloud • On-demand devices (multi-tenant) • Mobile App testing on over 1000+ real Android and iOS devices hosted by Bitbar Private Cloud PRODUCT UPDATE: XCTest & XCUITest Support Available On-Premise XCTest/XCUITest Supported
  • 4. • Integral framework in Xcode • Not a new framework: Xcode 5 introduced the first version of XCTest • Incrementally new capabilities/features: o Xcode 6 – performance measurement o Xcode 7 – UI testing (XCUITest) • Works with both Swift and Objective-C XCTest & XCUITest What isXCTest/XCUITest?
  • 5. • Easy to learn, no additional installations or components required (to Xcode) • Native iOS language support • Xcode Test Recorder (for XCUITest) • Integration with Xcode Server (continuous integration) and Bots • Faster than many other popular functional (and cross-platform) test frameworks • Works with both Swift and Objective-C XCTest Pros of XCTest
  • 6. • No cross-platform support • Limited programming language support • Selectors may seem complex • Requires (always) a separate test target • Signing can be ‘tricky’ • Sometimes… well, flaky XCTest Cons of XCTest
  • 7. The Status of iOS Test Automation Frameworks
  • 8. • If you running a test script built for prior Xcode versions, all uia_* calls will raise an error with the latest Xcode • When upgrading to Xcode 8 all your existing UIAutomation scripts will fail Deprecated UI Automation MigratingUIA-> XCTest?
  • 9. The Basics of XCTest & XCUITest and How to Get Started New Ebook Available! Download This Guide
  • 10. • A test method is an instance method of a test class that begins with prefix “test” • Tests are simply classes and methods and e.g. @property and helper methods can be added to the class XCTest & XCUITest Getting Started -(void)testExample { XCTAssert(...); XCTAssertTrue(...); XCTAssertFalse(...); }
  • 11. • Tests are grouped into classes that are subclass from XCTestCase XCTest & XCUITest WritingTest Methods class DemoTest: XCTestCase { - (void)testExample { // This is an example of a functional test case. // Use XCTAssert and related functions } - (void)testPerformanceExample { // This is an example of a performance test case. [self measureBlock:^{ // Put the code you want to measure the time of here. }]; } }
  • 12. XCTest & XCUITest XCTestCase Example - Swift import UIKit import XCTest @testable import LocalizationDemo class LocalizationDemoTests: XCTestCase { override func setUp() { super.setUp() } override func tearDown() { super.tearDown() } func testMyModel() { // Example of a functional test case. var model = MyModel(name: "first", surname: "last"); XCTAssertEqual(model.a, "first"); XCTAssertNotEqual(model.b, "first"); } func testIfLocalizationWorks() { // This is an example of a functional test case. XCTAssert(true, "Pass") } }
  • 13. • A performance test takes a block of code (that is measured) and runs it ten times, collecting the average execution time and the standard deviation for the runs XCTest & XCUITest WritingPerformance Tests - (void) testAdditionPerformance { [self measureBlock:^{ // set the initial state [calcViewController press:[calcView viewWithTag: 6]]; // iterate for 100000 cycles of adding 2 for (int i=0; i<100000; i++) { [calcViewController press:[calcView viewWithTag:13]]; [calcViewController press:[calcView viewWithTag: 2]]; [calcViewController press:[calcView viewWithTag:12]]; } }]; }
  • 14. XCUIApplication • The XCUIApplication is basically a proxy for an app that can be launched and terminated • User can tell the application to run in testing mode by defining app as a “Target Application” in Xcode target settings Code Syntax (XCUITest) // Objective-C XCUIApplication *app = [[XCUIApplication alloc] init]; // Swift let app = XCUIApplication()
  • 15. XCUIElement • XCUIElement is the actual UI element in an iOS application • XCUIElement provides all the basics symbols and functions for UI element interactions • Gestures with XCTest include clicking UI elements (normal, double, pressing), interacting with the screen (swipe, pinch, zoom, rotate etc.) Code Syntax (XCUITest) // Click-based functions tap() doubleTap() twoFingerTap() tap(withNumberOfTaps: UInt, numberOfTouches: UInt) press(forDuration: TimeInterval) press(forDuration: TimeInterval, thenDragTo: XCUIElement) // Generic UI interactions swipeLeft() swipeRight() swipeUp() swipeDown() pinch(withScale: CGFloat, velocity: CGFloat) rotate(CGFloat, withVelocity: CGFloat)
  • 16. XCUIElement • XCUIElement is constructed using the actual user interface elements on the screen • XCUIElement inherits from NSObject • In order to perform any interaction (tap on this example) on a UI element the UI interactions are available for use. Code Syntax (XCUITest) XCUIApplication *app = [[XCUIApplication alloc] init]; XCUIElement *masterNavigationBar = app.navigationBars[@"Master"]; XCUIElement *editButton = masterNavigationBar.buttons[@"Edit"]; // Objective-C [masterNavigationBar.staticTexts[@"Master"] tap]; [editButton tap];
  • 17. • Two ways to create IPA for test automation 1. Working with Xcode 2. Working from Command Line • Test package can be built as APP file and zipped for cloud execution Preparing IPA and Test Package for Simultaneous Device Runs Methods to Create IPAand Test Package for Simultaneous Tests
  • 18. • By archiving any build package will be compatible with an iOS device • When your build is done and archiving has finished, select the build from Archive list and click “Export…” Working on Xcode to Create IPA for Testing 1. Archive Your Build
  • 19. • When the following window is shown, simply select “Save for Ad Hoc Deployment” and click Next. Working on Xcode to Create IPA for Testing 2. Select The Right Method
  • 20. • Use the same identify what you use in build settings for code signing. • If your project and Xcode is properly configured you should see the following type of dialog proposing the first usable identifier: Working on Xcode to Create IPA for Testing 3. Identify Yourself(andYourBuild)
  • 21. • It’s almost always recommended to include all possible device support for your app. • If you want to reduce the size of your IPA you can shrink it by selecting to support only certain devices and OS versions Working on Xcode to Create IPA for Testing 4. Select OS and Devices
  • 22. • This can be done Product -> Build for -> Testing menu: Working on Command Line to Create IPA for Testing 1. Select toBuildfor Testing
  • 23. • Next, select your project in Project Navigator and right click to “Show it in Finder”: Working on Command Line to Create IPA for Testing 2. Locate App Fileon HD
  • 24. • After Finder dialog has been opened and files are shown, just highlight the .app file and right-click to see copying option, as follows: Working on Command Line to Create IPA for Testing 3. Copy App FileProperly
  • 25. • After Finder dialog has been opened and files are shown, just highlight the .app file and right-click to see copying option, as follows: Working on Command Line to Create IPA for Testing 4. Create IPA from CMD $ mkdir /tmp/Payload $ cd /tmp/Payload $ cp -r /User/Path/Debug-iphoneos/LocalizationDemo.app . $ cd .. $ zip --symlinks -qr "LocalizationDemo.ipa" Payload $ ls -lrt LocalizationDemo.ipa -rw-r--r-- 1 username staff 0 Dec 16 12:42 LocalizationDemo.ipa
  • 26. • If building for iPhone 5 or iPhone 5C (with ARMv7 32-bit processor) devices, additional step is needed before creating the build. • Starting from Xcode 7, armv7s is no more part of the default $(ARCHS_STANDARD) and so should be added as a target build architecture Creating an IPA for iOS App Testing Good To Know!
  • 28. Top 3 iOS Test Automation Frameworks XCTEST/XCUITEST APPIUM CALABASH CROSS-PLATFORM No Yes Yes IOS Yes Yes Yes MOBILE WEB Yes Yes No LANGUAGE Obj-C/Swift Almost any Ruby TOOL FOR TEST CREATION Xcode Appium.app CLI (Human-Readable syntax) COMMUNITY Apple Community Community
  • 29. Demo Xcode 6 / 7 / 8