UI TESTING IN XCODE 7
COCOAHEADS CHICAGO | OCTOBER 2015
BY ELLEN SHAPIRO
VOKAL.IO | JUSTHUM.COM | @DESIGNATEDNERD
Slide 2
Slide 2 text
IF I DIDN'T KNOW THE DEVELOPERS WERE
EUROPEAN,
I'D SAY THIS NEW DECKSET THEME WAS DESIGNED BY A
PACKERS FAN
Slide 3
Slide 3 text
TESTING TESTING 123
Slide 4
Slide 4 text
No content
Slide 5
Slide 5 text
UI TESTING
VS.
UNIT TESTING
Slide 6
Slide 6 text
UNIT TESTING:
TEST EACH PIECE INDIVIDUALLY
Slide 7
Slide 7 text
INTEGRATION TESTING:
TEST HOW ALL THE PIECES WORK TOGETHER
Slide 8
Slide 8 text
UI TESTING:
TEST HOW ALL THE PIECES WORK TOGETHER
FOR THE USER
Slide 9
Slide 9 text
USERS GIVE EXACTLY
ZERO FUCKS
HOW WELL YOUR APP WORKS UNDER THE HOOD IF IT DOESN'T DO
WHAT THEY NEED IT TO DO
Slide 10
Slide 10 text
GENERAL
IOS UI TESTING
CONCEPTS
Slide 11
Slide 11 text
TEST THE HAPPY PATH
AND THE KNOWN BAD PATH
Slide 12
Slide 12 text
ACCESSIBILITY
Slide 13
Slide 13 text
YOUR COMPUTER
IS BLIND
Slide 14
Slide 14 text
SEE WHAT YOUR COMPUTER SEES
(AND BLIND USERS WILL HEAR)
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
No content
Slide 17
Slide 17 text
No content
Slide 18
Slide 18 text
THE NEW HOTNESS:
XCUI TESTING
Slide 19
Slide 19 text
XCUI: WHAT IS?
> Added by Apple as part of Xcode 7 + iOS 9
> Takes Javascript out of UIAutomation
> Allows you to record actions
> Automatically refactors code as you record*
*-SORT OF
Slide 20
Slide 20 text
XCUI: HOW WORK?
> Builds queries against views
> Finds elements using those queries
> Element requests are evaluated on-demand
> Test runs in separate process than your app
Slide 21
Slide 21 text
.value VS. .label
Slide 22
Slide 22 text
XCUI DEMO
Slide 23
Slide 23 text
XCUI VS. KIF
Slide 24
Slide 24 text
KIF: WHAT IS?
> "Keep It Functional"
> Built and open-sourced by Square
> Huge, gnarly codebase, but it's open-source
> Runs anywhere XCTest does (iOS 7+)
Slide 25
Slide 25 text
KIF: HOW WORK?
> Uses private methods to tap and swipe through the app
> Runs in the same process as your app
> YOU reset your your UI before each test
Slide 26
Slide 26 text
KIF DEMO
Slide 27
Slide 27 text
STUPID
XCUI TRICKS*
*AS OF XCODE 7.0.1
Slide 28
Slide 28 text
No content
Slide 29
Slide 29 text
APP MUST RELAUNCH FROM SCRATCH
EVERY. SINGLE. TEST.
Slide 30
Slide 30 text
No content
Slide 31
Slide 31 text
TURN OFF THE
ACCESSIBILITY INSPECTOR
BEFORE USING UI RECORDING
Slide 32
Slide 32 text
SCROLLING
SADS
Slide 33
Slide 33 text
No content
Slide 34
Slide 34 text
HARD-CODED STRINGS ARE
EEEEVERYWHERE
AND GETTING RID OF THEM IS STUPIDER THAN USUAL
Slide 35
Slide 35 text
No content
Slide 36
Slide 36 text
No content
Slide 37
Slide 37 text
No content
Slide 38
Slide 38 text
No content
Slide 39
Slide 39 text
!
Slide 40
Slide 40 text
CENTRALIZE
YOUR TEST CODE
Slide 41
Slide 41 text
OBLIGATORY SUMMARY SLIDE
> UI Testing helps make sure all the pieces of your app
are working together
> Accessibility labels != accessibility identifiers
> XCUI testing still has some significant holes
> tap things to get a shortcut to what they are in code
> Don't repeat yourself applies to tests too!