Patterns of Automation: Simplify Your Test Code

641 views
523 views

Published on

Many organizations are introducing test automation only to discover it is more difficult than they anticipated. The fact is that good test automation requires good coding practices. Good test automation requires good design. To do anything else will lead to spaghetti code that is hard to maintain or update. If you’re new to coding or new to automation, it is difficult to know where to begin. Join Cheezy as he describes and demonstrates lessons he has learned while helping numerous organizations adopt test automation. Cheezy shows the patterns he uses to keep automation code simple and clean, and demonstrates techniques you can use to make your automation code more maintainable. Finally, Cheezy writes code (without a net) to implement these patterns, taking them from theory to implementation.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
641
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
13
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Patterns of Automation: Simplify Your Test Code

  1. 1. T3 Test Automation 5/8/2014 9:45:00 AM Patterns of Automation: Simplify Your Test Code Presented by: Jeff Morgan LeanDog Brought to you by: 340 Corporate Way, Suite 300, Orange Park, FL 32073 888-268-8770 ∙ 904-278-0524 ∙ sqeinfo@sqe.com ∙ www.sqe.com
  2. 2. Jeff Morgan LeanDog Chief technology officer and a cofounder of LeanDog, Jeff “Cheezy” Morgan has been teaching classes and coaching teams on agile and lean techniques since early 2004. Most of his work has focused on the engineering practices used by developers and testers. For the past few years Cheezy has experienced great success and recognition for his work focused on helping teams adopt Acceptance Test Driven Development using Cucumber. He has authored several popular Ruby gems used by software testers and the book Cucumber & Cheese-A Testers Workshop.
  3. 3. Patterns of Automation Jeff “Cheezy” Morgan @chzy cheezy@leandog.com
  4. 4. Copyright 2012 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Life is good
  5. 5. Why Automate?
  6. 6. Manual Testing (not ET) 1
  7. 7. Manual Testing (not ET) 1 1.5
  8. 8. Manual Testing (not ET) 1 1.5 2.2
  9. 9. Manual Testing (not ET) 1 1.5 2.2 3.0 4.0 5.3 6.4
  10. 10. Test What?
  11. 11. Test What? • Functionality
  12. 12. Test What? • Functionality • Cross-Browser
  13. 13. Test What? • Functionality • Cross-Browser • Responsive Design
  14. 14. Test What? • Functionality • Cross-Browser • Responsive Design • Mobile Devices
  15. 15. Test What? • Functionality • Cross-Browser • Responsive Design • Mobile Devices • Security
  16. 16. Test What? • Functionality • Cross-Browser • Responsive Design • Mobile Devices • Security • Accessibility
  17. 17. Test What? • Functionality • Cross-Browser • Responsive Design • Mobile Devices • Security • Accessibility • Load and Performance
  18. 18. Allows time to Explore • Functionality • Cross-Browser • Responsive Design • Mobile Devices • Security • Accessibility • Load and Performance
  19. 19. What are Patterns?
  20. 20. Pattern A pattern, apart from the term's use to mean "Template"[a], is a discernible regularity in the world or in a manmade design. As such, the elements of a pattern repeat in a predictable manner.! - Wikipedia
  21. 21. Specification by Example
  22. 22. Development Artifacts User Story with Acceptance Criteria Code with Unit Tests Automated Tests Specification Implementation Verification
  23. 23. Development Artifacts User Story with Acceptance Criteria Code with Unit Tests Automated Tests Specification Implementation Verification Duplication
  24. 24. Difference between requirement and test is data!
  25. 25. Addition Function
  26. 26. Addition Function Requirement: Addition equals sum of numbers
  27. 27. Addition Function Requirement: Addition equals sum of numbers Examples: 3 + 4 = 7 3 + -1 = 2 etc.
  28. 28. Let’s see it!
  29. 29. Did you notice I never said click or enter text?
  30. 30. Acceptance Test Driven Development
  31. 31. Rework Code Test Story 1
  32. 32. Rework Code Test Code Test Story 1 Story 2
  33. 33. Rework Code Test Story 1 Story 2 C Story 1 Test Code Test Story 2 C
  34. 34. Rework Code Test Story 1 Story 2 C Story 1 Test Story 2 C C Story 1 Test Code Test Story 2 C
  35. 35. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Test Review Done Product Owner Developer Tester
  36. 36. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Test Review Done Product Owner Developer Tester
  37. 37. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Test Review Done Product Owner Developer Tester
  38. 38. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Test Review Done Product Owner Developer Tester
  39. 39. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Test Review Done Product Owner Developer Tester
  40. 40. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Review Done Product Owner Developer Tester
  41. 41. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Review Done Product Owner Developer Tester
  42. 42. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Review Done Product Owner Developer Tester
  43. 43. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Review Done Product Owner Developer Tester
  44. 44. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Review Done Product Owner Developer Tester
  45. 45. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Review Done Product Owner Developer Tester ?
  46. 46. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Review Done Product Owner Developer Tester
  47. 47. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Review Done Product Owner Developer Tester
  48. 48. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Review Done Product Owner Developer Tester
  49. 49. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Review Done Product Owner Developer Tester Done
  50. 50. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Review Done Product Owner Developer Tester Done
  51. 51. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Review Done Product Owner Developer Tester Done Done
  52. 52. Code Test
  53. 53. Code Test
  54. 54. Code Test Developer Tester
  55. 55. Test Drive Code With Pair Code Test Developer Tester
  56. 56. Test Drive Code With Pair Code Test Developer Tester
  57. 57. Test Drive Code With Pair Automate Acceptance Tests Code Test Developer Tester
  58. 58. Test Drive Code With Pair Automate Acceptance Tests Code Test Developer Tester
  59. 59. Make Acceptance Tests Pass Test Drive Code With Pair Automate Acceptance Tests Code Test Developer Tester
  60. 60. Make Acceptance Tests Pass Test Drive Code With Pair Automate Acceptance Tests Code Test Developer Tester
  61. 61. Make Acceptance Tests Pass Test Drive Code With Pair Automate Acceptance Tests Code Test Developer Tester Exploratory Testing
  62. 62. Make Acceptance Tests Pass Test Drive Code With Pair Automate Acceptance Tests Code Test Developer Tester Exploratory Testing
  63. 63. Make Acceptance Tests Pass Talk Test Drive Code With Pair Automate Acceptance Tests Code Test Developer Tester Exploratory Testing
  64. 64. Make Acceptance Tests Pass Talk Test Drive Code With Pair Automate Acceptance Tests Code Test Developer Tester Exploratory Testing
  65. 65. Make Acceptance Tests Pass Talk Prevent Defects Test Drive Code With Pair Automate Acceptance Tests Code Test Developer Tester Exploratory Testing
  66. 66. Make Acceptance Tests Pass Talk Prevent Defects Test Drive Code With Pair Automate Acceptance Tests Code Test Developer Tester Exploratory Testing
  67. 67. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Creation Elaboration Validation WIP Product Owner
  68. 68. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Creation Elaboration Validation WIP Product Owner Tester
  69. 69. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Creation Elaboration Validation WIP Product Owner Tester Developer
  70. 70. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Creation Elaboration Validation WIP Product Owner Tester Developer
  71. 71. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Creation Elaboration Validation WIP Product Owner Tester Developer Progressive Elaboration
  72. 72. Page Object
  73. 73. Tests break when application changes ! How easy to fix?
  74. 74. Learn from the development community
  75. 75. Learn from the development community
  76. 76. Let’s see it!
  77. 77. Default Data
  78. 78. A lot of Data
  79. 79. A lot of Data Sorry Data, I don’t care about most of you!
  80. 80. Let’s see it!
  81. 81. Test Data Management
  82. 82. Why did you tests fail? Did somebody mess with your data?
  83. 83. Test begins Insert data needed for this test Test executes Test removes data Best Repeat for next test
  84. 84. Test begins Insert data needed for this test Test executes Test removes data Best Repeat for next test Another option Insert all data necessary for all tests Execute all tests Remove all data
  85. 85. Test begins Insert data needed for this test Test executes Test removes data Best Repeat for next test Another option Insert all data necessary for all tests Execute all tests Remove all data Yet another option Recondition data from last test execution Execute all tests
  86. 86. Do not repeat data Do not repeat data Do not repeat data Do not repeat data Do not repeat data Do not repeat data Do not repeat data
  87. 87. Route Navigation
  88. 88. Navigating routes is something we do all the time
  89. 89. Let’s see it!
  90. 90. Above All Keep the code clean
  91. 91. And
  92. 92. Do not Automate too much!
  93. 93. Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. cheezy@leandog.com @chzy Thank You

×