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

Automated Mobile Acceptance Testing Workshop - ...

Pete Hodgson
March 14, 2013
170

Automated Mobile Acceptance Testing Workshop - mdevcon 2013

Pete Hodgson

March 14, 2013
Tweet

Transcript

  1. Mobile Acceptance Testing Workshop mdevcon 2013 did you do the

    setup steps? github.com/moredip/mdevcon-workshop Thursday, March 14, 13
  2. The Plan some theory, but centered on practical know-how lots

    of opportunities for hands on Thursday, March 14, 13
  3. The Plan focus will be iOS and Frank but almost

    all concepts are generally applicable Thursday, March 14, 13
  4. Agenda the value of testing acceptance testing fundamentals selecting bits

    of UI interacting with bits of UI inspecting bits of UI “advanced stuff” Thursday, March 14, 13
  5. The Goal leave here feeling empowered to write your first

    automated acceptance tests Thursday, March 14, 13
  6. launch the app > cd your_app_directory > frank launch LAUNCHING

    IN THE SIMULATOR... Thursday, March 14, 13
  7. manual test script Scenario: adding a new counter - launch

    app - tap + to add a new counter - choose a CountUp counter - enter “My Group” as a group name - enter “My Counter” as a counter name - tap Save - check you are back on the main screen - check you see your group and counter name - check that tapping the counter makes it count Thursday, March 14, 13
  8. manual test script Scenario: adding a new counter - launch

    app - tap + to add a new counter - choose a CountUp counter - enter “My Group” as a group name - enter “My Counter” as a counter name - tap Save - check you are back on the main screen - check you see your group and counter name - check that tapping the counter makes it count again Thursday, March 14, 13
  9. what have we discovered? - testing is a way to

    explore the app - testing can be tedious - humans tend to optimize - humans tend to make mistakes Thursday, March 14, 13
  10. running our first automated test > cd your_app_directory > frank

    build > cucumber Frank/features Thursday, March 14, 13
  11. why do we test? interacting with the app to see

    what it does Thursday, March 14, 13
  12. and we’re not very good at it ... manual testing

    is tedious ... Thursday, March 14, 13
  13. but computers are ... and we’re not very good at

    it ... manual testing is tedious ... Thursday, March 14, 13
  14. “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 Thursday, March 14, 13
  15. why automate your tests - more time for exploratory QA

    - consistency in our testing Thursday, March 14, 13
  16. why automate your tests - more time for exploratory QA

    - consistency in our testing - drives focus on requirements Thursday, March 14, 13
  17. why automate your tests - more time for exploratory QA

    - consistency in our testing - drives focus on requirements - protect against regressions Thursday, March 14, 13
  18. why automate your tests - more time for exploratory QA

    - consistency in our testing - drives focus on requirements - protect against regressions - enable courageous change Thursday, March 14, 13
  19. why automate your tests - more time for exploratory QA

    - consistency in our testing - drives focus on requirements - protect against regressions - enable courageous change - what else? Thursday, March 14, 13
  20. a few reliable tests are better than lots of flakey

    tests ProTiptm Thursday, March 14, 13
  21. select a bit o UI simulate interaction with it inspect

    state o it Thursday, March 14, 13
  22. view selectors - a little language to specify which views

    to inspect/ interact with - like CSS or XPath Thursday, March 14, 13
  23. frank console > cd your_app_directory > frank launch > frank

    console connecting to app... connected [1] pry(#<Frank::Console>)> Thursday, March 14, 13
  24. back in the console > selector = “button marked:‘Edit’” >

    element_exists( selector ) => true > frankly_map( selector, ‘isEnabled’ ) => [true] > frankly_map( selector, ‘isHidden’ ) => [false] > frankly_map( selector, ‘accessibilityFrame’ ) => [{"size"=>{"width"=>50, "height"=>30}, "origin"=>{"x"=>5, "y"=>27}}] Thursday, March 14, 13
  25. back in the console > touch “view marked:‘Add’” > touch

    “label marked:'CountUp'” > touch “view:'UITextFieldLabel' marked:'Group Name'” > type_into_keyboard “My Group” > touch “view:'UITextFieldLabel' marked:'Counter Name'” > type_into_keyboard “My Counter” > touch “button marked:'Save'” > element_exists “view marked:’My Group’” > element_exists “view marked:’My Counter’” > touch “view marked:’My Counter’” Thursday, March 14, 13
  26. cucumber Given I have a simple counter And I have

    counted to 10 When I reset the counter Then the counter should be at 0 Thursday, March 14, 13
  27. Cucumber steps Given I have a simple counter And I

    have counted to 10 When I reset the counter Then the counter should be at 0 Thursday, March 14, 13
  28. Cucumber step definitions When /^I reset the counter$/ do touch(

    “view marked:‘Zero Counts’” ) end Thursday, March 14, 13
  29. Cucumber step definitions When /^I reset the counter$/ do touch(

    “view marked:‘Zero Counts’” ) end Thursday, March 14, 13
  30. Cucumber step definitions When /^I reset the counter$/ do touch(

    “view marked:‘Zero Counts’” ) end Thursday, March 14, 13
  31. ... ... touch “button marked:'CountUp'” touch “view marked:'Group Name'” type_into_keyboard

    “my group” touch “view marked:'Counter Name'” type_into_keyboard “my counter” touch “button marked:‘Save’” ... ... Thursday, March 14, 13
  32. When /^I create a "(.*?)" counter$/ do |counter| touch “button

    marked:'CountUp'” touch “view marked:'Group Name'” type_into_keyboard DEFAULT_GROUP_NAME touch “view marked:'Counter Name'” type_into_keyboard counter touch “button marked:‘Save’” end Thursday, March 14, 13
  33. When /^I create a "(.*?)" counter$/ do |counter| touch “button

    marked:'CountUp'” touch “view marked:'Group Name'” type_into_keyboard DEFAULT_GROUP_NAME touch “view marked:'Counter Name'” type_into_keyboard counter touch “button marked:‘Save’” end Thursday, March 14, 13
  34. When /^I create a "(.*?)" counter$/ do |counter| touch “button

    marked:'CountUp'” touch “view marked:'Group Name'” type_into_keyboard DEFAULT_GROUP_NAME touch “view marked:'Counter Name'” type_into_keyboard counter touch “button marked:‘Save’” end Thursday, March 14, 13
  35. When /^I create a "(.*?)" counter$/ do |counter| touch “button

    marked:'CountUp'” touch “view marked:'Group Name'” type_into_keyboard DEFAULT_GROUP_NAME touch “view marked:'Counter Name'” type_into_keyboard counter touch “button marked:‘Save’” end Thursday, March 14, 13
  36. what about the network?      touch

    “button marked:‘Login’” check_element_exists “view marked:‘Welcome back!’” Thursday, March 14, 13
  37. what about the network?      touch

    “button marked:‘Login’” check_element_exists “view marked:‘Welcome back!’” Thursday, March 14, 13
  38. what about the network?    touch “button marked:‘Login’”

    check_element_exists “view marked:‘Welcome back!’” Thursday, March 14, 13
  39. what about the network?    touch “button marked:‘Login’”

    check_element_exists “view marked:‘Welcome back!’” Thursday, March 14, 13
  40. what about the network?    touch “button marked:‘Login’”

    check_element_exists “view marked:‘Welcome back!’” fail Thursday, March 14, 13
  41. what about the network?      touch

    “button marked:‘Login’” check_element_exists “view marked:‘Welcome back!’” fail Thursday, March 14, 13
  42. a tempting solution touch “button marked:‘Login’” sleep 2 check_element_exists “view

    marked:‘Welcome back!’” PROBLEM slow tests Thursday, March 14, 13
  43. a tempting solution touch “button marked:‘Login’” sleep 2 check_element_exists “view

    marked:‘Welcome back!’” PROBLEM slow tests PROBLEM fragile tests Thursday, March 14, 13
  44. wrapping up the value of testing (feedback) definition of an

    acceptance test selecting/interacting/inspecting frank console and symbiote “advanced stuff” Thursday, March 14, 13
  45. further research - ‘Page Object’ pattern - Spin Asserts -

    Quarantine broken tests - acceptance testing Journeys - Continuous Integration - faking out external services Thursday, March 14, 13
  46. helpful resources testingwithfrank.com the cucumber book the rspec book scripting

    w. Ruby book specification by example book rubymine (good IDE for ruby/cuke dev.) eradicating non- determinism in tests (good blog post) creating maintainable acceptance tests (presentation slides and video) the example tests in the Frank repo Thursday, March 14, 13