Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Better UI Testing With Swift Robots - Forward Swift, San Francisco, March 2017

Better UI Testing With Swift Robots - Forward Swift, San Francisco, March 2017

Video:
https://www.youtube.com/watch?v=flZDWc25paw

[Apologies for talking reallydamnedfast, I thought my slot was way longer than it actually was. Oops!]

My deck on using the Robot pattern for more readable, more flexible tests in Swift.

Codez: https://github.com/designatednerd/GoCubs

Ellen Shapiro

March 02, 2017
Tweet

More Decks by Ellen Shapiro

Other Decks in Technology

Transcript

  1. ! ! ! ! ! ! ! ! ! !

    Better UI testing with Swift Robots Forward Swift | San Francisco, CA | March 2017 @designatednerd | spothero.com | justhum.com ! ! ! ! ! ! ! ! ! !
  2. KIF

  3. ! ! ! ! ! ! ! ! ! ROBOTS

    ! ! ! ! ! ! ! ! !
  4. KIF

  5. Subclassing XCTest directly: ✅ class GoCubsXCUITests: XCTestCase { ❌ class

    GoCubsKIFTests: KIFTestCase { ✅ class GoCubsEarlGreyTests: XCTestCase {
  6. Using the protocol instead: !!!!!!!!!!!!!!!!!!!!!!!!!!!! class GoCubsXCUITests: XCTestCase, RobotTests {

    class GoCubsKIFTests: KIFTestCase, RobotTests { class GoCubsEarlGreyTests: XCTestCase, RobotTests { !!!!!!!!!!!!!!!!!!!!!!!!!!!!
  7. Using @testable import: ❌ class GoCubsXCUITests: XCTestCase, RobotTests { ✅

    class GoCubsKIFTests: KIFTestCase, RobotTests { ✅ class GoCubsEarlGreyTests: XCTestCase, RobotTests {
  8. Obligatory Summary Slide! Robots will help you: - Separate what

    what from how - Keep your tests readable
  9. Obligatory Summary Slide! Robots will help you: - Separate what

    what from how - Keep your tests readable - Swap out the underlying implementation
  10. Obligatory Summary Slide! Robots will help you: - Separate what

    what from how - Keep your tests readable - Swap out the underlying implementation FREE ADVICE:
  11. Obligatory Summary Slide! Robots will help you: - Separate what

    what from how - Keep your tests readable - Swap out the underlying implementation FREE ADVICE: - Giving techniques cool names makes it way more likely people will steal use them.
  12. Links! — Earl Grey: https://github.com/google/EarlGrey — KIF: https://github.com/kif-framework/KIF — Jake

    Wharton on Kotlin Robots: https://realm.io/ news/kau-jake-wharton-testing-robots/ — Joe Masilotti on XCTest Helpers: http:// masilotti.com/xctest-helpers/
  13. Photo Credits! — "Earl Grey" by Ana Ulin https://www.flickr.com/ photos/anaulin/164424396/

    — "maybe now I'll get my texts" by frankieleon https://www.flickr.com/photos/ armydre2008/3935008214 — Cubs Winning The World Series, by Matt Slocum, AP https://www.nytimes.com/2016/11/03/sports/ baseball/chicago-cubs-beat-cleveland-indians- world-series-game-7.html