patterns of a “good” test automation framework
TRANSCRIPT
![Page 1: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/1.jpg)
PATTERNS OF A “GOOD” TEST AUTOMATION FRAMEWORK!
Anand Bagmar
Software Quality Evangelist
![Page 2: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/2.jpg)
ABOUT ME
@BagmarAnand
Blog - essenceoftesting
about.me/anand.bagmar
![Page 3: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/3.jpg)
WHAT DO YOU EXPECT FROM THIS SESSION?
![Page 4: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/4.jpg)
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
![Page 5: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/5.jpg)
Disclaimer
![Page 6: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/6.jpg)
![Page 7: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/7.jpg)
What is a Pattern?
![Page 8: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/8.jpg)
![Page 9: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/9.jpg)
https://en.wikipedia.org/wiki/Software_design_pattern
![Page 10: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/10.jpg)
Have you heard-of or used any
Pattern(s) in Test Automation?
![Page 11: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/11.jpg)
COMMON PATTERNS USED IN TEST AUTOMATION
¨ Page-Object
¨ Business Layer
¨ Singleton
¨ Composition
¨ Factory
¨ Builder
![Page 12: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/12.jpg)
Test Automation Framework Patterns
![Page 13: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/13.jpg)
![Page 14: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/14.jpg)
Code sample - #1
![Page 15: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/15.jpg)
Page-Object Pattern
![Page 16: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/16.jpg)
PAGE OBJECT PATTERN
Model pagesin code
Simulates user actions
One place change
Reduces code duplication
Snippets of page
![Page 17: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/17.jpg)
![Page 18: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/18.jpg)
Code sample - #2
![Page 19: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/19.jpg)
AUTOMATION FRAMEWORK WITH PAGE OBJECTS
![Page 20: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/20.jpg)
LIMITATIONS OF PAGE-OBJECT PATTERN
¨ Test intent gets polluted
¨ Duplication of Test intent & implementation
¨ Intent becomes Imperative
¨ Maintenance challenges
¨ Scaling challenges
![Page 21: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/21.jpg)
Business-Layer
Page-Object Pattern
![Page 22: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/22.jpg)
BUSINESS-LAYER PAGE-OBJECT PATTERN
![Page 23: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/23.jpg)
Code sample - #3
![Page 24: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/24.jpg)
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’
![Page 25: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/25.jpg)
Test Data Patterns
![Page 26: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/26.jpg)
Why do we need to think differently about Test Data?
![Page 27: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/27.jpg)
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
![Page 28: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/28.jpg)
DIFFERENT WAYS TO SPECIFY TEST DATA
¨ In Test implementation
¨ In Test specification / intent
¨ In code … separate data structures / classes / etc.
¨ External files
![Page 29: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/29.jpg)
TEST DATA SPECIFICATION EXAMPLES
¨ Excel
¨ CSV
¨ Property
¨ XML
¨ YAML
¨ Database
¨ Json
![Page 30: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/30.jpg)
Code sample - #4
![Page 31: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/31.jpg)
CRITERIA FOR SELECTION
¨ Easy to specify
¨ Easy to read and consume (by test framework)
¨ Ability to override specified data, easily
¨ Usable
![Page 32: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/32.jpg)
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.
![Page 33: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/33.jpg)
Locators’ Patterns
![Page 34: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/34.jpg)
DIFFERENT WAYS TO SPECIFY ELEMENT LOCATORS
¨ In Page-Objects
¨ In separate files, per Page-Object
¨ In external files / locator files
![Page 35: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/35.jpg)
Advantages of using Patterns for Test Automation
![Page 36: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/36.jpg)
ADVANTAGES OF PATTERNS
¨ Well known, well understood
¨ Tried & tested solutions for common problems
¨ Reduces complexity
¨ Language neutral
¨ Aid in communication
![Page 37: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/37.jpg)
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
![Page 38: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/38.jpg)
WHICH IS THE “BEST” PATTERN TO USE ?
![Page 39: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/39.jpg)
It DEPENDS!on the
Context!
![Page 40: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/40.jpg)
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
![Page 41: Patterns of a “good” test automation framework](https://reader031.vdocuments.net/reader031/viewer/2022022205/58d124e71a28ab2a738b621f/html5/thumbnails/41.jpg)
@BagmarAnand
Blog - essenceoftesting
about.me/anand.bagmar
THANK YOU