Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

SauceCon19: Fashionable XCUITest for iOS App

327 views

Published on

SauceCon19 talk on Fashionable XCUITest for iOS apps. You can watch video
https://www.youtube.com/watch?v=nODHDfZhSQU

Published in: Software
  • Be the first to comment

  • Be the first to like this

SauceCon19: Fashionable XCUITest for iOS App

  1. 1. Fashionable XCUITest for iOS Apps SauceCon 2019 Shashikant Jagtap @Shashikant86
  2. 2. About Me • Shashikant Jagtap [ XCTEQ Limited ] • Background: Mobile DevOps, CI/CD & Test Automation • XCUITest, XCTest, Swift,  Developer Tools, CI Scripting • XCBLOG [https://shashikantjagtap.net] @Shashikant86
  3. 3. Topics • State of iOS App Testing • XCUITest • Protocol Oriented Test Design Pattern • Tips and Tricks for DevOps friendly XCUITests @Shashikant86
  4. 4. iOS Testing without XCUITest • Heavy Manual Testing • Use of third-party tools • Slow and Flaky Test Automation • Hard to integrate with CI/CD pipeline @Shashikant86
  5. 5. XCUITest • Xcode UI Testing framework from  • Allows UI Testing using Swift or Objective-C programming languages • Based on Accessibility technology • Black Box @Shashikant86
  6. 6. How to learn XCUITest • Apple WWDC Videos
 https://developer.apple.com/videos/play/wwdc2015/406/ • Apple Official Documentation on UI Testing 
 https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/09-ui_testing.html • Test Automation University Course on XCUITest 
 https://testautomationu.applitools.com/introduction-to-ios-test-automation-with-xcuitest/ @Shashikant86
  7. 7. XCUITest Test Design Pattern • Page Object Pattern or Screen Play Pattern @Shashikant86
  8. 8. XCUITest Test Design Pattern • Page Object Pattern or Screen Play Pattern • Why? @Shashikant86
  9. 9. XCUITest Test Design Pattern • Page Object Pattern or Screen Play Pattern • Why? • Swift is protocol oriented language 
 https://developer.apple.com/videos/play/wwdc2015/408/ @Shashikant86
  10. 10. XCUITest Test Design Pattern • Page Object Pattern or Screen Play Pattern • Why? • Swift is protocol oriented language 
 https://developer.apple.com/videos/play/wwdc2015/408/ • We can use Protocol Oriented Approach for test designing too! @Shashikant86
  11. 11. Protocol Oriented XCUITest @Shashikant86 https://testautomationu.applitools.com/introduction-to-ios-test-automation-with-xcuitest/
  12. 12. Protocol Oriented XCUITest • Scalable Steps across UI Test Target • One Suite for both iPad and Phone • Human Readable and Re-usable Steps with XCTActivity • Easy to Configure on CI @Shashikant86
  13. 13. Effective XCTest for iOS • Use XCTest for all kinds of tests. Unit, Integration, API, UI and Performance Testing @Shashikant86
  14. 14. Effective XCTest for iOS • Use XCTest for all kinds of tests. Unit, Integration, API, UI and Performance Testing • Make Accessibility Identifiers mandatory all UI elements @Shashikant86
  15. 15. Effective XCTest for iOS • Use XCTest for all kinds of tests. Unit, Integration, API, UI and Performance Testing • Make Accessibility Identifiers mandatory all UI elements • Separate Configuration for testing. Don’t use debug or release. @Shashikant86
  16. 16. Effective XCTest for iOS • Use XCTest for all kinds of tests. Unit, Integration, API, UI and Performance Testing • Make Accessibility Identifiers mandatory all UI elements • Separate Configuration for testing. Don’t use debug or release • Think if testing on real devices required? @Shashikant86
  17. 17. Effective XCTest for iOS • Use XCTest for all kinds of tests. Unit, Integration, API, UI and Performance Testing • Make Accessibility Identifiers mandatory all UI elements • Separate Configuration for testing. Don’t use debug or release • Think if testing on real devices required? • Write loads of API and Contract Tests, Reduce the burden on UI testing @Shashikant86
  18. 18. Effective XCTest for iOS • Use XCTest for all kinds of tests. Unit, Integration, API, UI and Performance Testing • Make Accessibility Identifiers mandatory all UI elements • Separate Configuration for testing. Don’t use debug or release • Think if testing on real devices required? • Write loads of API and Contract Tests, Reduce the burden on UI testing • Write performance tests for detecting run time issues @Shashikant86
  19. 19. Effective XCTest for iOS • Use XCTest for all kinds of tests. Unit, Integration, API, UI and Performance Testing • Make Accessibility Identifiers mandatory all UI elements • Separate Configuration for testing. Don’t use debug or release • Think if testing on real devices required? • Write loads of API and Contract Tests, Reduce the burden on UI testing • Write performance tests for detecting run time issues • Keep separate Xcode schemes for UI and Performance tests @Shashikant86
  20. 20. Stub/Mock for XCUITest • Stubbing or mocking is hard with Swift. Harder for XCUITest @Shashikant86
  21. 21. Stub/Mock for XCUITest • Stubbing or mocking is hard with Swift. Harder for XCUITest • Launch Arguments Or Launch Environments in application code @Shashikant86
  22. 22. Stub/Mock for XCUITest • Stubbing or mocking is hard with Swift. Harder for XCUITest • Launch Arguments Or Launch Environments in application code • Local Networking Stubbing ( Swifter, Embassy, SBTUITestTunnel, Server Side Swift framework, SwiftLocalhost etc) @Shashikant86
  23. 23. Stub/Mock for XCUITest • Stubbing or mocking is hard with Swift. Harder for XCUITest • Launch Arguments Or Launch Environments in application code • Local Networking Stubbing ( Swifter, Embassy, SBTUITestTunnel, Server Side Swift framework, SwiftLocalhost etc) • Stub if really needed. Keep UI tests as real tests. @Shashikant86
  24. 24. CI Friendly XCUITest • Select smart CI Server/Services @Shashikant86
  25. 25. CI Friendly XCUITest • Select smart CI Server/Services • Avoid third party tools/Services if possible for shorter build time @Shashikant86
  26. 26. CI Friendly XCUITest • Select smart CI Server/Services • Avoid third party tools/Services if possible for shorter build time • Don’t build app twice. Use build-for-testing and test-without-building option from xcodebuild tool @Shashikant86
  27. 27. CI Friendly XCUITest • Select smart CI Server/Services • Avoid third party tools/Services if possible for shorter build time • Don’t build app twice. Use build-for-testing and test-without-building option from xcodebuild tool • Avoid Flaky CI scripting, Keep it native. @Shashikant86
  28. 28. CI Friendly XCUITest • Select smart CI Server/Services • Avoid third party tools/Services if possible for shorter build time • Don’t build app twice. Use build-for-testing and test-without-building option from xcodebuild tool • Avoid Flaky CI scripting, Keep it native. • Smart parallelisation of XCTest to speed up builds @Shashikant86
  29. 29. Dealing with Flakiness • You can’t simply avoid flakiness in UI tests ( trade-off ) @Shashikant86
  30. 30. Dealing with Flakiness • You can’t simply avoid flakiness in UI tests ( trade-off ) • UI Tests != Unit Tests @Shashikant86
  31. 31. Dealing with Flakiness • You can’t simply avoid flakiness in UI tests ( trade-off ) • UI Tests != Unit Tests • Root of flakiness aren not your test. It can be anything out of your control. e.g Environment, Flaky app architecture, Test data, Network etc @Shashikant86
  32. 32. Dealing with Flakiness • You can’t simply avoid flakiness in UI tests ( trade-off ) • UI Tests != Unit Tests • Root of flakiness aren not your test. It can be anything out of your control. e.g Environment, Flaky app architecture, Test data, Network etc @Shashikant86
  33. 33. Dealing with Flakiness • “Your test code requires maintenance. There is no getting around this.”
 Angie Jones 
 
 [ https://dzone.com/articles/testing-in-ci ] @Shashikant86
  34. 34. Benefits of XCUITest • Native and Fast • Collaboration with app developers • Easy to integrate with CI/CD • Enhance the accessibility of the iOS apps • Maintained by Apple @Shashikant86
  35. 35. Excuses for not using XCUITest • XCUITest is great but we made decision in the past to use other third-party tool. We invested heavily in it. @Shashikant86
  36. 36. Excuses for not using XCUITest • XCUITest is great but we made decision in the past to use other third-party tool. We invested heavily in it. • We want cross-platform solution for both iOS and Android @Shashikant86
  37. 37. Excuses for not using XCUITest • XCUITest is great but we made decision in the past to use other third-party tool. We invested heavily in it. • We want cross-platform solution for both iOS and Android • Where should we find engineers with Swift and XCUITest skills? @Shashikant86
  38. 38. Excuses for not using XCUITest • XCUITest is great but we made decision in the past to use other third-party tool. We invested heavily in it. • We want cross-platform solution for both iOS and Android • Where should we find engineers with Swift and XCUITest skills? • It’s still a new and buggy! @Shashikant86
  39. 39. Excuses for not using XCUITest • XCUITest is great but we made decision in the past to use other third-party tool. We invested heavily in it. • We want cross-platform solution for both iOS and Android • Where should we find engineers with Swift and XCUITest skills? • It’s still a new and buggy! • We keep using existing tool as long as it works. @Shashikant86
  40. 40. Recap • XCUITest should be used for native iOS Apps • Cross-platform mobile development, you can choose cross-platform testing tools • XCUITest gives chance to collaborate with developers and finds internal issues in the app. @Shashikant86
  41. 41. Question Time @Shashikant86
  42. 42. Thanks • Contact Me: @Shashikant86 • Email: shashikant.jagtap@xcteq.co.uk • Website: [ https://shashikantjagtap.net ] @Shashikant86

×