SlideShare a Scribd company logo
Simplifying test automation
with design patterns
Ivan Pashko
Speaker info
Ivan Pashko, Ukraine
Scrum Master in Betsson, Ciklum
• 8+ years in the IT
• Software Automation Developer
/in/ivan-pashko-33208042/
/groups/1180099188730673
Code smell
Clean code
Code is clean if it can be understood
easily – by everyone on the team, going
over a long time
Ivan Pashko - Simplifying test automation with design patterns
Why Design Patterns?
General repeatable solution to a commonly occurring
problem in software design.
Test smells
• Test Code Duplication
• Conditional Test Logic
• Obscure Test
• Fragile Test
Test smells
• copy/paste
• if-else
• inheritance /overrides
• data sensivity (hardcode, magic values)
Test smell. Copy/Paste
• Duplication increases
the cost of maintenance
Template Method
• Defines the skeleton of
an algorithm in an
operation,
• Deferring some steps to
subclasses
Template Method
public class MonitoringNotificationBaseTest<T> where T : BaseNotificationData
/// <summary>
/// Method perform next steps:
/// 1. Create New Notification
/// 2. Update Notification
/// 3. Check Enable/Disable Button
/// 4. Remove Notification
/// </summary>
/// <param name="defaultNotification">Used in 1 step</param>
/// <param name="updatedNotification">Used in 2 step</param>
public void CRUDNotificationTest(T defaultNotification, T updatedNotification)
{
CreateNewNotification(defaultNotification);
UpdateNotification(updatedNotification);
CheckEnableDisableButton();
RemoveNotification();
}
Test smell. Conditional Test Logic
Makes tests more complicated than
they really should be.
if (element.Exist())
{
AssertElementContext(element);
}
else
{
AssertErrorMessageAppeared();
}
if (element != null)
{
element.Click();
}
• What condition is
passed?
• What if condition failed,
but test is green?
• What is test fail?
Test smell. Conditional Test Logic
Strategy Pattern
Enables an algorithm's behavior to be selected at
runtime
Factory Pattern
• Hides the logic of
initializing an object
inside the factory.
• Refers to the object
using a common
interface instead of
the concrete class.
Test smell. Inheritance /overrides
Blind inheritance and overrides leads to the
creation of «Monster» objects
Composite Pattern
• The composite pattern
describes a group of
objects that is treated the
same way as a single
instance of the same type
of object.
Decorator Pattern
• Attach additional
responsibilities to an
object dynamically.
• Revealing Naming
• Replace Magic Numbers
with constants
• Use builder for defaults
& complex object
creation
//Revealing naming
List<string> list1
List<string> userNames
//Magic numbers as constants
FindByAge(33);
const int OLD_USER_AGE = 33;
FindByAge(OLD_USER_AGE);
Test smell. Data sensitivity
Builder Pattern
Separates the construction of a complex object from
its representation
Builder Pattern
public class User
{
//Required parameters:
public string Email { get; set; }
public string Login { get; set; }
//Additional parameters:
public string Name { get; set; }
public int Age { get; set; }
public string Address { get; set; }
}
• Typical test user object:
• Required fields
• Additional fields
Builder Pattern
//Telescoping constructor
new User(email, login);
new User(email, login, "test name", 18, "test address");
//JavaBeans
new User("test@gmail.com", "test_123")
{
Name = "Name",
Age = 18,
Address = "test address"
};
• Copy / paste
• Constructor overrides
• Helpers methods
As a result:
• A lot of code
• Duplicates
• Unclear defaults
Builder Pattern
new UserBuilder("test@gmail.com", "user_123")
.Name("Name")
.Age(18)
.Address("test address")
.Build();
public UserBuilder(string email, string login)
{
_user = new User(email, login)
{
//Default values:
Name = "Default Name",
Age = 18,
Address = "Default address"
};
}
• Easy to read
• Simple to extend
• Safe defaults
Your test smells if
• contains if’s
• has a ‘twin brother’
• depends on the data
• doesn’t feet in one screen
• bypass your framework
Good test
is like a
good joke
- it needs no explanation
Thank you
Useful links:
http://blog.bbv.ch/wp-content/uploads/2013/06/Clean-Code-V2.1.pdf
http://xunitpatterns.com
https://sourcemaking.com
Questions?
You can also ask questions for me in the lounge zone

More Related Content

What's hot (19)

PPTX
Keyword-driven Test Automation Framework
Mikhail Subach
 
PPTX
A Test Automation Framework
Gregory Solovey
 
PPT
Centralized test automation framework implementation
Bharathi Krishnamurthi
 
PDF
Test automation methodologies
Mesut Günes
 
PPTX
Introduction to Automation Testing
Archana Krushnan
 
PPTX
Software Automation Testing Introduction
Narayanan Palani
 
PPS
Final Automation Testing
priya_trivedi
 
PPT
Checklist for website testing
Tricode (part of Dept)
 
PPT
Automation framework
ITeLearn
 
PDF
Automated Testing
John Paulett
 
PPTX
Uft Basics
Archana Krushnan
 
PPT
Introduction to Gauge
vodqancr
 
PPTX
Test automation
Xavier Yin
 
PPTX
Automation testing
Mona M. Abd El-Rahman
 
PPTX
Unit testing
princezzlove
 
PDF
Hands-on Experience Model based testing with spec explorer
Rachid Kherrazi
 
PPT
Test Automation Framework Designs
Sauce Labs
 
PPT
Hybrid Automation Framework Development introduction
Ganuka Yashantha
 
PDF
Behavior Driven Development with SpecFlow
Rachid Kherrazi
 
Keyword-driven Test Automation Framework
Mikhail Subach
 
A Test Automation Framework
Gregory Solovey
 
Centralized test automation framework implementation
Bharathi Krishnamurthi
 
Test automation methodologies
Mesut Günes
 
Introduction to Automation Testing
Archana Krushnan
 
Software Automation Testing Introduction
Narayanan Palani
 
Final Automation Testing
priya_trivedi
 
Checklist for website testing
Tricode (part of Dept)
 
Automation framework
ITeLearn
 
Automated Testing
John Paulett
 
Uft Basics
Archana Krushnan
 
Introduction to Gauge
vodqancr
 
Test automation
Xavier Yin
 
Automation testing
Mona M. Abd El-Rahman
 
Unit testing
princezzlove
 
Hands-on Experience Model based testing with spec explorer
Rachid Kherrazi
 
Test Automation Framework Designs
Sauce Labs
 
Hybrid Automation Framework Development introduction
Ganuka Yashantha
 
Behavior Driven Development with SpecFlow
Rachid Kherrazi
 

Similar to Ivan Pashko - Simplifying test automation with design patterns (20)

PPT
Design_Patterns_Dr.CM.ppt
C Meenakshi Meyyappan
 
PPTX
Software System Architecture-Lecture 6.pptx
ssuser9a23691
 
PPTX
Selenium Design Patterns
Liraz Shay
 
PDF
The maze of Design Patterns & SOLID Principles
Muhammad Raza
 
PPTX
UNIT V TESTING.pptx
anguraju1
 
PDF
Test Automation Design Patterns_ A Comprehensive Guide.pdf
flufftailshop
 
PDF
Test Automation Design Patterns_ A Comprehensive Guide.pdf
kalichargn70th171
 
PPTX
TDD Training
Manuela Grindei
 
PDF
Keeping code clean
Brett Child
 
PDF
Design patterns
Anas Alpure
 
PPTX
Introduction to Design Patterns
Prageeth Sandakalum
 
PPTX
Principles and patterns for test driven development
Stephen Fuqua
 
PDF
Test-Driven Development
Amir Assad
 
PDF
Design Patterns Java programming language.pdf
totallyrealmail420
 
PPTX
Iterative architecture
JoshuaRizzo4
 
PPTX
Design patterns
F(x) Data Labs Pvt Ltd
 
PDF
Presentation on design pattern software project lll
Uchiha Shahin
 
PPTX
Writing testable code
apursani
 
PPTX
Design patterns(red)
Fahad A. Shaikh
 
Design_Patterns_Dr.CM.ppt
C Meenakshi Meyyappan
 
Software System Architecture-Lecture 6.pptx
ssuser9a23691
 
Selenium Design Patterns
Liraz Shay
 
The maze of Design Patterns & SOLID Principles
Muhammad Raza
 
UNIT V TESTING.pptx
anguraju1
 
Test Automation Design Patterns_ A Comprehensive Guide.pdf
flufftailshop
 
Test Automation Design Patterns_ A Comprehensive Guide.pdf
kalichargn70th171
 
TDD Training
Manuela Grindei
 
Keeping code clean
Brett Child
 
Design patterns
Anas Alpure
 
Introduction to Design Patterns
Prageeth Sandakalum
 
Principles and patterns for test driven development
Stephen Fuqua
 
Test-Driven Development
Amir Assad
 
Design Patterns Java programming language.pdf
totallyrealmail420
 
Iterative architecture
JoshuaRizzo4
 
Design patterns
F(x) Data Labs Pvt Ltd
 
Presentation on design pattern software project lll
Uchiha Shahin
 
Writing testable code
apursani
 
Design patterns(red)
Fahad A. Shaikh
 
Ad

More from Ievgenii Katsan (20)

PDF
8 andrew kalyuzhin - 30 ux-advices, that will make users love you
Ievgenii Katsan
 
PDF
5 hans van loenhoud - master-class the 7 skills of highly successful teams
Ievgenii Katsan
 
PDF
4 alexey orlov - life of product in startup and enterprise
Ievgenii Katsan
 
PDF
3 dmitry gomeniuk - how to make data-driven decisions in saa s products
Ievgenii Katsan
 
PDF
7 hans van loenhoud - the problem-goal-solution trinity
Ievgenii Katsan
 
PDF
1 hans van loenhoud -
Ievgenii Katsan
 
PDF
3 denys gobov - change request specification the knowledge base or the task...
Ievgenii Katsan
 
PDF
5 victoria cupet - learn to play business analysis
Ievgenii Katsan
 
PDF
5 alina petrenko - key requirements elicitation during the first contact wi...
Ievgenii Katsan
 
PDF
3 karabak kuyavets transformation of business analyst to product owner
Ievgenii Katsan
 
PDF
4 andrii melnykov - stakeholder management for pd ms and b-as and why it is...
Ievgenii Katsan
 
PDF
3 zornitsa nikolova - the product manager between decision making and facil...
Ievgenii Katsan
 
PDF
4 viktoriya gudym - how to effectively manage remote employees
Ievgenii Katsan
 
PDF
9 natali renska - product and outsource development, how to cook 2 meals in...
Ievgenii Katsan
 
PDF
7 denis parkhomenko - from idea to execution how to make a product that cus...
Ievgenii Katsan
 
PDF
6 anton vitiaz - inside the mvp in 3 days
Ievgenii Katsan
 
PDF
5 mariya popova - ideal product management. unicorns in our reality
Ievgenii Katsan
 
PDF
2 victor podzubanov - design thinking game
Ievgenii Katsan
 
PDF
3 sergiy potapov - analyst to product owner
Ievgenii Katsan
 
PDF
4 anton parkhomenko - how to make effective user research with no budget at...
Ievgenii Katsan
 
8 andrew kalyuzhin - 30 ux-advices, that will make users love you
Ievgenii Katsan
 
5 hans van loenhoud - master-class the 7 skills of highly successful teams
Ievgenii Katsan
 
4 alexey orlov - life of product in startup and enterprise
Ievgenii Katsan
 
3 dmitry gomeniuk - how to make data-driven decisions in saa s products
Ievgenii Katsan
 
7 hans van loenhoud - the problem-goal-solution trinity
Ievgenii Katsan
 
1 hans van loenhoud -
Ievgenii Katsan
 
3 denys gobov - change request specification the knowledge base or the task...
Ievgenii Katsan
 
5 victoria cupet - learn to play business analysis
Ievgenii Katsan
 
5 alina petrenko - key requirements elicitation during the first contact wi...
Ievgenii Katsan
 
3 karabak kuyavets transformation of business analyst to product owner
Ievgenii Katsan
 
4 andrii melnykov - stakeholder management for pd ms and b-as and why it is...
Ievgenii Katsan
 
3 zornitsa nikolova - the product manager between decision making and facil...
Ievgenii Katsan
 
4 viktoriya gudym - how to effectively manage remote employees
Ievgenii Katsan
 
9 natali renska - product and outsource development, how to cook 2 meals in...
Ievgenii Katsan
 
7 denis parkhomenko - from idea to execution how to make a product that cus...
Ievgenii Katsan
 
6 anton vitiaz - inside the mvp in 3 days
Ievgenii Katsan
 
5 mariya popova - ideal product management. unicorns in our reality
Ievgenii Katsan
 
2 victor podzubanov - design thinking game
Ievgenii Katsan
 
3 sergiy potapov - analyst to product owner
Ievgenii Katsan
 
4 anton parkhomenko - how to make effective user research with no budget at...
Ievgenii Katsan
 
Ad

Recently uploaded (20)

PPTX
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
PPT
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 
PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PPTX
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
PPTX
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
PROGRAMMING REQUESTS/RESPONSES WITH GREATFREE IN THE CLOUD ENVIRONMENT
samueljackson3773
 
PDF
Artificial Neural Network-Types,Perceptron,Problems
Sharmila Chidaravalli
 
PPTX
UNIT 1 - INTRODUCTION TO AI and AI tools and basic concept
gokuld13012005
 
PDF
Tesia Dobrydnia - An Avid Hiker And Backpacker
Tesia Dobrydnia
 
PDF
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PDF
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
PDF
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
PDF
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
PDF
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
PDF
Bachelor of information technology syll
SudarsanAssistantPro
 
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
Distribution reservoir and service storage pptx
dhanashree78
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PROGRAMMING REQUESTS/RESPONSES WITH GREATFREE IN THE CLOUD ENVIRONMENT
samueljackson3773
 
Artificial Neural Network-Types,Perceptron,Problems
Sharmila Chidaravalli
 
UNIT 1 - INTRODUCTION TO AI and AI tools and basic concept
gokuld13012005
 
Tesia Dobrydnia - An Avid Hiker And Backpacker
Tesia Dobrydnia
 
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
Bachelor of information technology syll
SudarsanAssistantPro
 

Ivan Pashko - Simplifying test automation with design patterns