Download presentation
2
Software Design Patterns in Test Automation
3
Table of Content Objectives What are Design Patterns?
Design Pattern and Design Principle - what's the difference? Principles KISS Don’t Repeat Yourself. 5. Patterns Multi-layered test solution Facade Chaining Template Method
4
Objectives Present the concepts of „design pattern” & „design 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.
5
Software Design Pattern
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
6
Pattern vs Principle 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
7
KISS Keep it simple stupid. (KISS)
8
KISS – Example
9
KISS – Example
10
Solution
11
DRY Don’t Repeat yourself (DRY)
12
DRY - Example
13
Solution
14
Time for Patterns
15
Multi Layered Test Solution
Strategy Multi Layered Test Solution
16
Overview
17
Example
18
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
19
Facade Facade
20
Facade provides an unified interface in subsystem.
Facade – description Facade provides an unified interface in subsystem. Defines a higher-level interface that makes the subsystem easier to use.
21
Facade – UML
22
Verify if PayPal is available payment method
Facade - Test Case Login as Normal User Add product to cart Go to checkout Verify if PayPal is available payment method
23
Facade – Before
24
Facade –After
25
Facade – Front Facade Implementation
26
Less time spent on writing new test cases Easier maintenance.
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.
27
Methods Chaining
28
Methods Chaining- Example
29
Chaining – methods difference
30
Pros & Cons Helps when writing tests Clean Code & Readability
Person can’t see what object is returned Chain breaks
31
Template Method
32
Template 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.
33
Template Method– UML
34
Template Method -Test Cases
Buy Product Go To Checkout Validate PayPal Payment Buy Product Go To Checkout Validate Payment On Delivery
35
Template Method - Example
36
Template Method - Example
37
Quite hard to understand To understand what going on in test
Pros & Cons Avoiding God Class Modularization Quite hard to understand To understand what going on in test ‚little digging’ is neccesary
38
Design patterns are more like guidelines
Summary Design patterns are more like guidelines Patterns can be bad if used in wrong context Anybody can use them Do not force patterns into your code!!! Anti-Patterns
39
Head First Design Patterns – O’Reily Media
Bibliography Head First Design Patterns – O’Reily Media Design Patterns: Elements of Reusable Object-Oriented Software
40
Questions?
41
Contact Us
42
Thank you for your attention
Krzysztof Wilczyński & Maciej Wyrodek
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.