SlideShare a Scribd company logo
Automated Xcode 7
UI Testing
HelsinkiOS 26 August 2015
Xcode 7 Features
— Testability. Write tests of Swift 2.0 frameworks and apps
with access to all your public and internal routines
— User interface testing and recording. Test applications
at the user interface surface with elements, queries, and
simulated events. The UI recording feature enables
capture of UI actions into source to facilitate creating
tests (DEMO)
— App thinning (iOS 9 SDK), Xcode bots + OS X Server
with on demand resources (ou-es ten server)
Xcode 7 Features (cont)
— Free Provisioning. Develop on your own device,
mechanism to provision and install development
project on physical devices for testing and
evaluation.
— Code coverage. Provides report information to
evaluate a test suite for completeness.
Code Coverage
— Visualize the completeness of your test suite by
enabling code coverage for your scheme. The code
coverage tab in the test report shows which files,
functions and lines of code were exercised and, more
importantly, which were not exercised. The source
code editor can also show code coverage information
inline, allowing you to see at a glance which lines—
and parts of a line—the tests exercised. (3555436)
Automated Xcode 7 UI Testing
Beta 4
— Using UI recording generates code for iOS gestures
like doubleTap, twoFingerTap, longPress, swipeUp,
swipeDown, swipeLeft, and swipeRight. (20278248)
— Code coverage works with UI testing. (20966994)
Beta 5
— Code Coverage now supports files in static libraries.
The source files show up under each binary that links
the static library in the Coverage tab of the Test
Report. The source editor shows coverage numbers
aggregated across all binaries. (21984681)
Beta 6
— XCTest offers API to automate complex controls such as date
pickers. (20577276)
— Apps with names that contain parenthesis can be exported from
the Archives organizer. (22142125)
— Ability to interact with hardware buttons, like
XCUIDeviceButtonHome.
— Ability to interact with XCUIElementTypeSlider and
XCUIElementTypePickerWheel
— Ability to handle alerts that gets in the way with the new add/
removeUIInterruptionMonitor APIs
Known Problems (Beta 6)
— UI testing cannot identify elements using information from their
accessibility title element. Workaround: Set an accessibility
identifier instead. (20409319)
— UI testing cannot record or interact with popovers on OS X.
(21162677)
— UI tests do not support key modifiers on iOS. (20185910,
21033224)
— When recording a UI Test for an OS X app, Xcode Helper, not
Xcode, asks to use the Accessibility APIs. This app uses the
Accessibility APIs when running UI Tests. (21211897)
Syntax -XCUIApplication
— Proxy to application, separate from app (runs in
separate process)
— Can control when to launch or terminate app
app.launchEnvironment = ["myValue": "value"]
app.launch()
if let value = NSProcessInfo.processInfo().environment["myValue"]
{
// do something with value
}
Syntax -XCUIElement
— Application is a tree of elements with hierarchy
(think DOM tree)
— Element must be unique
— Based on UIControl (button, table cell, window)
— Accessibility identifier, label, title, etc.
— Custom element visibility e.g. via Interface Builder
Accessibility Inspector
Syntax -XCUIElementQuery
— Must resolve to single element, otherwise failure
— Evaluated on-demand and re-evaluated when used
(think URL lifecycle)
— "exists" property can be used to safely test elements
— Elements visible via accessibility
— Relationships and filtering
— Chain queries
Syntax -XCTest Assertions 1
XCTAssert(expression, format...)
XCTAssertTrue(expression, format...)
XCTAssertFalse(expression, format...)
XCTAssertEqual(expression1, expression2, format...)
XCTAssertNotEqual(expression1, expression2, format...)
XCTAssertEqualWithAccuracy(expression1, expression2, accuracy, format...)
XCTAssertNotEqualWithAccuracy(expression1, expression2, accuracy, format...)
XCTAssertNil(expression, format...)
XCTAssertNotNil(expression, format...)
XCTAssertNil(expression, format...)
XCTAssertNotNil(expression, format...)
1
XCTestCase / XCTestExpectation / measureBlock() at NSHipster
Debug
— Use breakpoints in test cases
— Same familiar LLDB debugger and commands 2
— Test reports at Xcode Report Navigator
— Automatic screenshots
— Just re-record test cases, it's that easy !!!
2
About LLDB and Xcode by Apple
Demo...awesome !!! Just look at that dynamic realtime code
refactoring, when recording test cases O_O
More info
— Xcode 7 Beta 6 Release Notes
— WWDC 2015 video + PDF 406: UI Testing in Xcode
— WWDC 2015 video + PDF 410: Continuous Integration and
Code Coverage in Xcode
— WWDC 2014 video + PDF 415: Continuous Integration with
Xcode 6
— XCTest and UI Testing documentation by Joe Maselotti
— XCTestCase / XCTestExpectation / measureBlock() at NSHipster
— UIAccessibility documentation by Apple
Thank You!
Any questions? SlideShare.
Jouni Miettunen - jouni.miettunen@gmail.com
@jomtwi
at Elisa Software Services, looking for mobile
developers

More Related Content

PDF
Xcode7 UI Automation
PDF
iOS UIAutomation
PDF
Xcode 7 UI Testing - Xcake Dublin, October 2015
PDF
iOS UI Testing in Xcode
PPTX
XCUITest for iOS App Testing and how to test with Xcode
PPTX
iOS Automation: XCUITest + Gherkin
PDF
Testing iOS10 Apps with Appium and its new XCUITest backend
Xcode7 UI Automation
iOS UIAutomation
Xcode 7 UI Testing - Xcake Dublin, October 2015
iOS UI Testing in Xcode
XCUITest for iOS App Testing and how to test with Xcode
iOS Automation: XCUITest + Gherkin
Testing iOS10 Apps with Appium and its new XCUITest backend

What's hot (20)

KEY
SWTBot Tutorial
PPTX
SwtBot: Unit Testing Made Easy
PPT
Swtbot
PDF
UI testing in Xcode 7
PDF
Functional Testing made easy with SWTBot for Developers and Testers
PDF
iOS UI Automation
PDF
Taras Kalapun ui testing
PPT
JsUnit
PDF
Android UI Testing with Espresso
PDF
Client-side JavaScript
ODP
Developing Java SWT Applications - A Starter
PPT
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
PPTX
Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...
PDF
Steps how to create active x using visual studio 2008
PDF
UI Testing Best Practices - An Expected Journey
PPT
Top 3 SWT Exceptions
PPT
Lightning Talk - iOS UI Automated Testing
PDF
WinAppDriver - Windows Store Apps Test Automation
PDF
Feedback using Angularjs + Typescript at Serenytics
PPT
Tellurium 0.7.0 presentation
SWTBot Tutorial
SwtBot: Unit Testing Made Easy
Swtbot
UI testing in Xcode 7
Functional Testing made easy with SWTBot for Developers and Testers
iOS UI Automation
Taras Kalapun ui testing
JsUnit
Android UI Testing with Espresso
Client-side JavaScript
Developing Java SWT Applications - A Starter
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...
Steps how to create active x using visual studio 2008
UI Testing Best Practices - An Expected Journey
Top 3 SWT Exceptions
Lightning Talk - iOS UI Automated Testing
WinAppDriver - Windows Store Apps Test Automation
Feedback using Angularjs + Typescript at Serenytics
Tellurium 0.7.0 presentation
Ad

Viewers also liked (6)

PDF
Page Object in XCUITest
PPTX
Getting Started with XCTest and XCUITest for iOS App Testing
KEY
iOS Unit Testing
PDF
[XCode] Automating UI Testing
PDF
iOS Test-Driven Development
PDF
Static Swift Code Analysis - The Background Story
Page Object in XCUITest
Getting Started with XCTest and XCUITest for iOS App Testing
iOS Unit Testing
[XCode] Automating UI Testing
iOS Test-Driven Development
Static Swift Code Analysis - The Background Story
Ad

Similar to Automated Xcode 7 UI Testing (20)

PDF
Understanding XCUITest Framework Your Guide to Efficient iOS Testing.pdf
PPT
GUI design using JAVAFX.ppt
PDF
UI Automation_White_CodedUI common problems and tricks
PPTX
Coded UI: Hand Coding based on Page Object Model
PDF
Stmik bandung
PPTX
awt and swing new (Abstract Window Toolkit).pptx
PDF
PDF
Visual Studio commands
PDF
Testing Tools
DOCX
Selenium Testing Training in Bangalore
PDF
System verilog important
PPTX
Developing Interactive systems - lesson 2
PPTX
open-west
PDF
automation framework
PDF
Swift
PDF
Manageable Robust Automated Ui Test
PPTX
Calabash-android
PPSX
Test Complete
PDF
Advanced Swift Generics
PDF
Automation strategies for agile testing Gaurav bansal
Understanding XCUITest Framework Your Guide to Efficient iOS Testing.pdf
GUI design using JAVAFX.ppt
UI Automation_White_CodedUI common problems and tricks
Coded UI: Hand Coding based on Page Object Model
Stmik bandung
awt and swing new (Abstract Window Toolkit).pptx
Visual Studio commands
Testing Tools
Selenium Testing Training in Bangalore
System verilog important
Developing Interactive systems - lesson 2
open-west
automation framework
Swift
Manageable Robust Automated Ui Test
Calabash-android
Test Complete
Advanced Swift Generics
Automation strategies for agile testing Gaurav bansal

Automated Xcode 7 UI Testing

  • 1. Automated Xcode 7 UI Testing HelsinkiOS 26 August 2015
  • 2. Xcode 7 Features — Testability. Write tests of Swift 2.0 frameworks and apps with access to all your public and internal routines — User interface testing and recording. Test applications at the user interface surface with elements, queries, and simulated events. The UI recording feature enables capture of UI actions into source to facilitate creating tests (DEMO) — App thinning (iOS 9 SDK), Xcode bots + OS X Server with on demand resources (ou-es ten server)
  • 3. Xcode 7 Features (cont) — Free Provisioning. Develop on your own device, mechanism to provision and install development project on physical devices for testing and evaluation. — Code coverage. Provides report information to evaluate a test suite for completeness.
  • 4. Code Coverage — Visualize the completeness of your test suite by enabling code coverage for your scheme. The code coverage tab in the test report shows which files, functions and lines of code were exercised and, more importantly, which were not exercised. The source code editor can also show code coverage information inline, allowing you to see at a glance which lines— and parts of a line—the tests exercised. (3555436)
  • 6. Beta 4 — Using UI recording generates code for iOS gestures like doubleTap, twoFingerTap, longPress, swipeUp, swipeDown, swipeLeft, and swipeRight. (20278248) — Code coverage works with UI testing. (20966994)
  • 7. Beta 5 — Code Coverage now supports files in static libraries. The source files show up under each binary that links the static library in the Coverage tab of the Test Report. The source editor shows coverage numbers aggregated across all binaries. (21984681)
  • 8. Beta 6 — XCTest offers API to automate complex controls such as date pickers. (20577276) — Apps with names that contain parenthesis can be exported from the Archives organizer. (22142125) — Ability to interact with hardware buttons, like XCUIDeviceButtonHome. — Ability to interact with XCUIElementTypeSlider and XCUIElementTypePickerWheel — Ability to handle alerts that gets in the way with the new add/ removeUIInterruptionMonitor APIs
  • 9. Known Problems (Beta 6) — UI testing cannot identify elements using information from their accessibility title element. Workaround: Set an accessibility identifier instead. (20409319) — UI testing cannot record or interact with popovers on OS X. (21162677) — UI tests do not support key modifiers on iOS. (20185910, 21033224) — When recording a UI Test for an OS X app, Xcode Helper, not Xcode, asks to use the Accessibility APIs. This app uses the Accessibility APIs when running UI Tests. (21211897)
  • 10. Syntax -XCUIApplication — Proxy to application, separate from app (runs in separate process) — Can control when to launch or terminate app app.launchEnvironment = ["myValue": "value"] app.launch() if let value = NSProcessInfo.processInfo().environment["myValue"] { // do something with value }
  • 11. Syntax -XCUIElement — Application is a tree of elements with hierarchy (think DOM tree) — Element must be unique — Based on UIControl (button, table cell, window) — Accessibility identifier, label, title, etc. — Custom element visibility e.g. via Interface Builder Accessibility Inspector
  • 12. Syntax -XCUIElementQuery — Must resolve to single element, otherwise failure — Evaluated on-demand and re-evaluated when used (think URL lifecycle) — "exists" property can be used to safely test elements — Elements visible via accessibility — Relationships and filtering — Chain queries
  • 13. Syntax -XCTest Assertions 1 XCTAssert(expression, format...) XCTAssertTrue(expression, format...) XCTAssertFalse(expression, format...) XCTAssertEqual(expression1, expression2, format...) XCTAssertNotEqual(expression1, expression2, format...) XCTAssertEqualWithAccuracy(expression1, expression2, accuracy, format...) XCTAssertNotEqualWithAccuracy(expression1, expression2, accuracy, format...) XCTAssertNil(expression, format...) XCTAssertNotNil(expression, format...) XCTAssertNil(expression, format...) XCTAssertNotNil(expression, format...) 1 XCTestCase / XCTestExpectation / measureBlock() at NSHipster
  • 14. Debug — Use breakpoints in test cases — Same familiar LLDB debugger and commands 2 — Test reports at Xcode Report Navigator — Automatic screenshots — Just re-record test cases, it's that easy !!! 2 About LLDB and Xcode by Apple
  • 15. Demo...awesome !!! Just look at that dynamic realtime code refactoring, when recording test cases O_O
  • 16. More info — Xcode 7 Beta 6 Release Notes — WWDC 2015 video + PDF 406: UI Testing in Xcode — WWDC 2015 video + PDF 410: Continuous Integration and Code Coverage in Xcode — WWDC 2014 video + PDF 415: Continuous Integration with Xcode 6 — XCTest and UI Testing documentation by Joe Maselotti — XCTestCase / XCTestExpectation / measureBlock() at NSHipster — UIAccessibility documentation by Apple
  • 17. Thank You! Any questions? SlideShare. Jouni Miettunen - [email protected] @jomtwi at Elisa Software Services, looking for mobile developers