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.

Patterns of a “good” test automation framework

6,157 views

Published on

Slides from my talk in Phoenix, AZ at STPCon about Patterns of a “good” test automation framework. See my blog for more details - https://essenceoftesting.blogspot.com/2017/03/patterns-in-test-automation-framework.html

Published in: Software

Patterns of a “good” test automation framework

  1. 1. PATTERNS OF A “GOOD” TEST AUTOMATION FRAMEWORK! Anand Bagmar Software Quality Evangelist
  2. 2. ABOUT ME @BagmarAnand Blog - essenceoftesting about.me/anand.bagmar
  3. 3. WHAT DO YOU EXPECT FROM THIS SESSION?
  4. 4. TELL ME ... ¨ Any Managers in the room? ¨ Developers / Testers / Automation “folks” in the room? ¨ What toolset do you use for Automation? ¨ How many automated tests do you have? ¨ Have you heard the phrase - ”Test Automation code should be of Production Quality”? ¨ Do you believe it? ¨ Anyone in the room does not code / understand code? 4
  5. 5. Disclaimer
  6. 6. What is a Pattern?
  7. 7. https://en.wikipedia.org/wiki/Software_design_pattern
  8. 8. Have you heard-of or used any Pattern(s) in Test Automation?
  9. 9. COMMON PATTERNS USED IN TEST AUTOMATION ¨ Page-Object ¨ Business Layer ¨ Singleton ¨ Composition ¨ Factory ¨ Builder
  10. 10. Test Automation Framework Patterns
  11. 11. Code sample - #1
  12. 12. Page-Object Pattern
  13. 13. PAGE OBJECT PATTERN Model pages in code Simulates user actions One place change Reduces code duplication Snippets of page
  14. 14. Code sample - #2
  15. 15. AUTOMATION FRAMEWORK WITH PAGE OBJECTS
  16. 16. LIMITATIONS OF PAGE-OBJECT PATTERN ¨ Test intent gets polluted ¨ Duplication of Test intent & implementation ¨ Intent becomes Imperative ¨ Maintenance challenges ¨ Scaling challenges
  17. 17. Business-Layer Page-Object Pattern
  18. 18. BUSINESS-LAYER PAGE-OBJECT PATTERN
  19. 19. Code sample - #3
  20. 20. ADVANTAGES OF BUSINESS-LAYER PAGE-OBJECT PATTERN ¨ Validate what is important - Business requirements ¨ Test Pyramid remains sane ¨ Abstraction layers allow separation-of-concerns ¨ Changes are isolated ¨ Maintenance & Scaling becomes ‘easier’
  21. 21. Test Data Patterns
  22. 22. Why do we need to think differently about Test Data?
  23. 23. CRITERIA FOR TEST DATA ¨ Data is complex ¨ Needs to mimic “real” data ¨ Needs to be unique ¨ Data can be nested ¨ Though specified as static, may need to be Dynamic ¨ Data can be shared and reused
  24. 24. DIFFERENT WAYS TO SPECIFY TEST DATA ¨ In Test implementation ¨ In Test specification / intent ¨ In code … separate data structures / classes / etc. ¨ External files
  25. 25. TEST DATA SPECIFICATION EXAMPLES ¨ Excel ¨ CSV ¨ Property ¨ XML ¨ YAML ¨ Database ¨ Json
  26. 26. Code sample - #4
  27. 27. CRITERIA FOR SELECTION ¨ Easy to specify ¨ Easy to read and consume (by test framework) ¨ Ability to override specified data, easily ¨ Usable
  28. 28. TIPS FOR IMPLEMENTATION ¨ Consistent way to specify test data ¨ Read the data – as Business Entities ¨ Override as appropriate ¨ Create DSL to give meaning to data ¨ Use in test implementation ¨ Implement Test Data Entity Utilities – Build, Equals, Copy, Find, etc.
  29. 29. Locators’ Patterns
  30. 30. DIFFERENT WAYS TO SPECIFY ELEMENT LOCATORS ¨ In Page-Objects ¨ In separate files, per Page-Object ¨ In external files / locator files
  31. 31. Advantages of using Patterns for Test Automation
  32. 32. ADVANTAGES OF PATTERNS ¨ Well known, well understood ¨ Tried & tested solutions for common problems ¨ Reduces complexity ¨ Language neutral ¨ Aid in communication
  33. 33. ADVANTAGES OF PATTERNS IN TEST AUTOMATION Saves time & effort (eventually) Single ownership Test Automation Code is of Production Quality! Single point of change Easy to – - Implement - Maintain - Debug - Scale
  34. 34. WHICH IS THE “BEST” PATTERN TO USE ?
  35. 35. It DEPENDS! on the Context!
  36. 36. REFERENCES Page Objects – Google https://code.google.com/p/selenium/wiki/PageObjects Page Objects – Martin Fowler http://martinfowler.com/bliki/PageObject.html Perils of Page-Object Pattern – Anand Bagmar http://essenceoftesting.blogspot.in/2014/09/perils-of-page-object-pattern.html Test Design Consideration http://docs.seleniumhq.org/docs/06_test_design_considerations.jsp Sample Test Framework implementation https://github.com/anandbagmar/cuke-jvm-sample
  37. 37. @BagmarAnand Blog - essenceoftesting about.me/anand.bagmar THANK YOU

×