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

Beyond UIAutomation

Pete Hodgson
October 27, 2012

Beyond UIAutomation

Slides from my CocoaConf PDX talk.

I covered some of the reasons that automated tests are valuable. I described some common challenges when doing automated UI tests, along with some solutions. I described why UIAutomation doesn't let us use all these solutions, and why we should look beyond UIAutomation.

Pete Hodgson

October 27, 2012
Tweet

More Decks by Pete Hodgson

Other Decks in Programming

Transcript

  1. Topics - why do automated testing - challenges and solutions

    - UIAutomation and beyond - hands on with Frank
  2. but computers are ... and we’re not very good at

    it ... manual testing is tedious ...
  3. “Computers are designed to do simple repetitive tasks. The second

    you have humans doing repetitive tasks, all the computers get together late at night and laugh at you…” - Neal Ford
  4. UIAutomation - runs inside Instruments - write test scripts in

    javascript - drives simulator or device - lives outside of the wider test automation ecosystem
  5. a basic test script touch “textField marked:‘login’” type_into_keyboard “testuser” touch

    “textField marked:‘password’” type_into_keyboard ‘testpassword’ touch “button marked:‘Login’”
  6. a basic test script touch “textField marked:‘login’” type_into_keyboard “testuser” touch

    “textField marked:‘password’” type_into_keyboard ‘testpassword’ touch “button marked:‘Login’”
  7. a basic test script touch “textField marked:‘login’” type_into_keyboard “testuser” touch

    “textField marked:‘password’” type_into_keyboard ‘testpassword’ touch “button marked:‘Login’” PROBLEM! no abstractions
  8. Given, When, Then Scenario: prompted to log in Given I

    am on the home screen But I am not logged in When I tap the Friends button Then I should be on the log in screen
  9. Given I am on the home screen But I am

    not logged in When I tap the Friends button Then I should be on the log in screen Cucumber steps
  10. Cucumber step definitions When /^I tap the Friends button$/ do

    touch( “button marked:‘Friends’” ) end
  11. Cucumber step definitions When /^I tap the Friends button$/ do

    touch( “button marked:‘Friends’” ) end
  12. Cucumber step definitions When /^I tap the Friends button$/ do

    touch( “button marked:‘Friends’” ) end
  13. ... ... touch “textField marked:‘login’” type_into_keyboard “testuser” touch “textField marked:‘password’”

    type_into_keyboard ‘testpassword’ touch “button marked:‘Login’” ... ...
  14. When /^I log in as "(.*?)"$/ do |user| password =

    password_for_user(user) touch “textField marked:‘login’” type_into_keyboard user touch “textField marked:‘password’” type_into_keyboard password touch “button marked:‘Login’” end
  15. When /^I log in as "(.*?)"$/ do |user| password =

    password_for_user(user) touch “textField marked:‘login’” type_into_keyboard user touch “textField marked:‘password’” type_into_keyboard password touch “button marked:‘Login’” end
  16. When /^I log in as "(.*?)"$/ do |user| password =

    password_for_user(user) touch “textField marked:‘login’” type_into_keyboard user touch “textField marked:‘password’” type_into_keyboard password touch “button marked:‘Login’” end
  17. When /^I log in as "(.*?)"$/ do |user| password =

    password_for_user(user) touch “textField marked:‘login’” type_into_keyboard user touch “textField marked:‘password’” type_into_keyboard password touch “button marked:‘Login’” end
  18. select the table cell labeled “Ham”? select the check box

    labeled “Ham”? select the 2nd check box?
  19. PROBLEM! brittle tests select the table cell labeled “Ham”? select

    the check box labeled “Ham”? select the 2nd check box?
  20. what about the network?      touch

    “button marked:‘Login’” check_element_exists “view marked:‘Welcome back!’”
  21. what about the network?      touch

    “button marked:‘Login’” check_element_exists “view marked:‘Welcome back!’”
  22. what about the network?    touch “button marked:‘Login’”

    check_element_exists “view marked:‘Welcome back!’”
  23. what about the network?    touch “button marked:‘Login’”

    check_element_exists “view marked:‘Welcome back!’”
  24. what about the network?    touch “button marked:‘Login’”

    check_element_exists “view marked:‘Welcome back!’” fail
  25. what about the network?      touch

    “button marked:‘Login’” check_element_exists “view marked:‘Welcome back!’” fail
  26. a tempting solution touch “button marked:‘Login’” sleep 2 check_element_exists “view

    marked:‘Welcome back!’” PROBLEM slow tests PROBLEM fragile tests
  27. services FAKE services Mustache designed by Dmitriy Lagunov from The

    Noun Project SOLUTION: test-only back-channel
  28. why go beyond UIAutomation lots of well-established solutions to these

    challenges ... ... but UIAutomation falls short.