Software Design Patterns in Test Automation
-
Upload
theresa-lucas -
Category
Documents
-
view
234 -
download
3
description
Transcript of Software Design Patterns in Test Automation
![Page 1: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/1.jpg)
![Page 2: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/2.jpg)
Software Design Patterns in Test Automation
![Page 3: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/3.jpg)
3
1. Objectives2. What are Design Patterns?3. Design Pattern and Design Principle - what's the difference?4. Principles KISS Don’t Repeat Yourself.5. Patterns Multi-layered test solution Facade Chaining Template Method
Table of Content
![Page 4: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/4.jpg)
Objectives• Present the concepts of „design pattern” & „de-sign principle” • Show why these concepts are important• Describe chosen patterns & principles.• All presented patterns have examples in C# but can be used with most Object-Oriented Languages• Target Audience: Testers who are writing automated tests and want to dive deeper into programing world.
![Page 5: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/5.jpg)
5
• General reusable solution to a commonly occuring problem within given context• Object-Oriented Desgin Patterns typically show relationships between classes and objects without specifing theirs final application.• (a pattern) „describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same ay twice„- Christopher Alexander
Software Design Pattern
![Page 6: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/6.jpg)
6
• Software Design Principle - Set of Guidelines that helps to avoid bad design and unmaintainable code.• „Design principles are the desirable goals that one aims to achieve. Design patterns are tools one can use to realize those goals. ” – E Arimitage
Pattern vs Principle
![Page 7: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/7.jpg)
Keep it simple stupid. (KISS)KISS
![Page 8: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/8.jpg)
KISS – Example 8
![Page 9: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/9.jpg)
9KISS – Example
![Page 10: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/10.jpg)
Solution
![Page 11: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/11.jpg)
Don’t Repeat yourself (DRY)
DRY
![Page 12: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/12.jpg)
12DRY - Example
![Page 13: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/13.jpg)
Solution
![Page 14: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/14.jpg)
Time for Patterns
![Page 15: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/15.jpg)
Multi Layered Test SolutionStrategy
![Page 16: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/16.jpg)
Overview
![Page 17: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/17.jpg)
Example
![Page 18: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/18.jpg)
Pros & Cons• Low maintenance effort and time• Enhanced code reusability• Structured codebase which is easy to fix and extend• Improved communication• Complexity• Time invested during creation• Experience
![Page 19: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/19.jpg)
FacadeFacade
![Page 20: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/20.jpg)
20Facade – description
Facade provides an unified interface in subsystem. Defines a higher-level interface that makes the subsystem easier to use.
![Page 21: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/21.jpg)
Facade – UML
![Page 22: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/22.jpg)
Facade - Test Case
• Login as Normal User • Add product to cart • Go to checkout• Verify if PayPal is available payment method
![Page 23: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/23.jpg)
Facade – Before
![Page 24: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/24.jpg)
Facade –After
![Page 25: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/25.jpg)
Facade – Front Facade Implementation
![Page 26: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/26.jpg)
Pros & Cons
• Less time spent on writing new test cases • Easier maintenance.• Test is harder to debug if it fails in ‚unexpected’ way.• Test is unreadable – if treated as an Unit Test.
![Page 27: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/27.jpg)
Methods Chaining
![Page 28: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/28.jpg)
Methods Chaining- Example
![Page 29: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/29.jpg)
Chaining – methods difference
![Page 30: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/30.jpg)
Pros & Cons
Helps when writing testsClean Code & ReadabilityPerson can’t see what object is returnedChain breaks
![Page 31: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/31.jpg)
Template Method
![Page 32: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/32.jpg)
32Template Method– description
Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.
![Page 33: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/33.jpg)
Template Method– UML
![Page 34: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/34.jpg)
Template Method -Test Cases
Buy Product Go To CheckoutValidate PayPal PaymentBuy Product Go To CheckoutValidate Payment On Delivery
![Page 35: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/35.jpg)
Template Method - Example
![Page 36: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/36.jpg)
Template Method - Example
![Page 37: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/37.jpg)
Pros & Cons• Avoiding God Class• Modularization• Quite hard to understand• To understand what going on in test ‚little digging’ is neccesary
![Page 38: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/38.jpg)
SummaryDesign patterns are more like guidelinesPatterns can be bad if used in wrong con-textAnybody can use themDo not force patterns into your code!!!Anti-Patterns
![Page 39: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/39.jpg)
Bibliographyhttp://dofactory.com/net/design-patternsHead First Design Patterns – O’Reily MediaDesign Patterns: Elements of Reusable Object-Oriented Software
![Page 40: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/40.jpg)
Questions?
![Page 42: Software Design Patterns in Test Automation](https://reader035.fdocuments.in/reader035/viewer/2022062223/5a4d1b637f8b9ab0599ae59a/html5/thumbnails/42.jpg)
Thank you for your attentionKrzysztof Wilczyński & Maciej Wyrodek