UI Testing in Xcode 7 - CocoaHeads Chicago, October 2015

UI Testing in Xcode 7 - CocoaHeads Chicago, October 2015

Initial look at UI testing in Xcode 7, both in general and specifically with XCUI tests and KIF tests.

NOTE: If you attended this talk, you'll see I updated the slide where I talked about trying to launch tests from the static setUp() method. Here's a video of me trying to make that work and the hilarisad result: https://www.youtube.com/watch?v=pR0iRf_2j7k

C4861b1dfdf3bbb21faec4a1acdf183d?s=128

Ellen Shapiro

October 14, 2015
Tweet

Transcript

  1. UI TESTING IN XCODE 7 COCOAHEADS CHICAGO | OCTOBER 2015

    BY ELLEN SHAPIRO VOKAL.IO | JUSTHUM.COM | @DESIGNATEDNERD
  2. IF I DIDN'T KNOW THE DEVELOPERS WERE EUROPEAN, I'D SAY

    THIS NEW DECKSET THEME WAS DESIGNED BY A PACKERS FAN
  3. TESTING TESTING 123

  4. None
  5. UI TESTING VS. UNIT TESTING

  6. UNIT TESTING: TEST EACH PIECE INDIVIDUALLY

  7. INTEGRATION TESTING: TEST HOW ALL THE PIECES WORK TOGETHER

  8. UI TESTING: TEST HOW ALL THE PIECES WORK TOGETHER FOR

    THE USER
  9. USERS GIVE EXACTLY ZERO FUCKS HOW WELL YOUR APP WORKS

    UNDER THE HOOD IF IT DOESN'T DO WHAT THEY NEED IT TO DO
  10. GENERAL IOS UI TESTING CONCEPTS

  11. TEST THE HAPPY PATH AND THE KNOWN BAD PATH

  12. ACCESSIBILITY

  13. YOUR COMPUTER IS BLIND

  14. SEE WHAT YOUR COMPUTER SEES (AND BLIND USERS WILL HEAR)

  15. None
  16. None
  17. None
  18. THE NEW HOTNESS: XCUI TESTING

  19. 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
  20. 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
  21. .value VS. .label

  22. XCUI DEMO

  23. XCUI VS. KIF

  24. 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+)
  25. 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
  26. KIF DEMO

  27. STUPID XCUI TRICKS* *AS OF XCODE 7.0.1

  28. None
  29. APP MUST RELAUNCH FROM SCRATCH EVERY. SINGLE. TEST.

  30. None
  31. TURN OFF THE ACCESSIBILITY INSPECTOR BEFORE USING UI RECORDING

  32. SCROLLING SADS

  33. None
  34. HARD-CODED STRINGS ARE EEEEVERYWHERE AND GETTING RID OF THEM IS

    STUPIDER THAN USUAL
  35. None
  36. None
  37. None
  38. None
  39. !

  40. CENTRALIZE YOUR TEST CODE

  41. 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!
  42. LINKS > Demo app: https://github.com/designatednerd/ GoCubs > Xcode UI Testing

    WWDC Session: https:// developer.apple.com/videos/play/ wwdc2015-406/ > UI Testing Gotchas from Big Nerd Ranch: https:// www.bignerdranch.com/blog/ui-testing-in- xcode-7-part-1-ui-testing-gotchas/