I
1
TEST
AUTOMATION
DESIGN
PATTERNS
7+ years in IT
TestOps / Test Automation missionary
---
Lead QA Engineer @ Mobiquity
Organizer @ QA Days
Participant @ Simplicity Day conference and others
2
VITALII
TATARYNOV
Agenda
Part 1: What is pattern?
Why do we need to use patterns? Or we don’t?
Part 2: Design patterns (practical part)
Let’s take a look to our code
Part 3: About QA Days
Why we organized QA Days?
Discussion on Meetup.com about patterns and
anti-patterns
3
Except of comprehensive automation planning
process, maintenance of your test-cases, manual
testing with all possible design technics, there are
three parts of go
Write
good
code
Collaborate
with your
team
Make a robust
scalable
infrastructure
(TestOps)
4
THREE PARTS
OF SUCCESSFUL
AUTOMATION
Except of comprehensive automation planning
process, maintenance of your test-cases, manual
testing with all possible design technics, there are
three parts of go
Collaborate
with your
team
5
THREE PARTS
OF SUCCESSFUL
AUTOMATION
Write
good
code
Make a robust
scalable
infrastructure
(TestOps)
Code is compiled,
tested and works
as expected
Code is
commented and
documented
Code is readable
understandable,
for other team
members
Code is scalable,
reusable and
STABLE
6
WHAT IS
GOOD AUTOTEST?
What is design pattern?
7
Benefits of patterns
Speed up the development process
Maintainable code
More readable code
It’s already verified and tested solution
8
Structural Creational Behavioral
9
TYPES OF PATTERNS?
STRUCTURAL
10
11
1. Describe the logic and POM
structure of tested application.
2. Make test logic part more readable.
3. Make your code reusable
PROBLEMS TO SOLVE
WHERE IS APPLICABLE:
Testing Web, Mobile, Desktop
application
12
PATTERN:
PAGE OBJECT
PATTERN
TYPE:
STRUCTURAL
Page Object Class:
Usage of Page Object Class:
13
1. Widely used to build a Domain
Specific Language (DSL) in
declarative way.
2. Used to make code shorter.
3. Used to structure calling of Page
Objects methods
PROBLEMS TO SOLVE
WHERE IS APPLICABLE:
Any automation framework
part.
Often used along with Page
Object pattern
14
Page Object Class:
PATTERN:
FLUENT INTERFACE
-
METHOD CHAINING
-
CHAIN OF
INVOCATIONS
TYPE:
STRUCTURAL
15
Test Class:
PATTERN:
FLUENT INTERFACE
-
METHOD CHAINING
-
CHAIN OF
INVOCATIONS
TYPE:
STRUCTURAL
16
1. Attach additional behaviour to
objects
PROBLEMS TO SOLVE
WHERE IS APPLICABLE:
Any part of test framework
17
PATTERNS:
DECORATOR
TYPE:
STRUCTURAL
Decorator implementation:
Usage of Decorator:
18
1. Hides the complexities of the
system
2. Give the access to interface of the
system to the “client”
PROBLEMS TO SOLVE
WHERE IS APPLICABLE:
API testing framework
19
PATTERNS:
FACADE
TYPE:
STRUCTURAL
Facade implementation:
Usage of Facade:
CREATIONAL
20
21
1. Encapsulate objects creation logic
2. Manage cross-platform systems
PROBLEMS TO SOLVE
WHERE IS APPLICABLE:
Testing cross-platform
applications (Web, Mobile,
Desktop).
To be used along with page
object
22
Page Object Classes:
Page Factory implementation:
PATTERN:
PAGE FACTORY
PATTERN
TYPE:
CREATIONAL
23
PATTERN:
PAGE FACTORY
PATTERN
TYPE:
CREATIONAL
24
1. Allows to construct complex
objects step by step.
2. Allows to separate the construction
of a complex object from its
representation.
3. Allows to avoid multiple complex
constructors
PROBLEMS TO SOLVE
WHERE IS APPLICABLE:
Test data
25
PATTERNS:
BUILDER
TYPE:
CREATIONAL
26
PATTERNS:
BUILDER
TYPE:
CREATIONAL
27
1. Create only one instance of the
object
2. Control concurrent access to a
shared resource.
PROBLEMS TO SOLVE
WHERE IS APPLICABLE:
Testing cross-platform
applications (Web, Mobile,
Desktop).
28
PATTERNS:
SINGLETON
TYPE:
CREATIONAL
BEHAVIORAL
29
30
1. Class behavior or its algorithm can
be changed at run time
2. Encapsulate each strategy, and
make them interchangeable.
3. Strategy lets the algorithm vary
independently from the clients that
use it.
PROBLEMS TO SOLVE
WHERE IS APPLICABLE:
Testing cross-platform
applications (Web, Mobile,
Desktop).
31
PATTERNS:
STRATEGY
TYPE:
BEHAVIORAL
32
PATTERNS:
STRATEGY
TYPE:
BEHAVIORAL
DATA PATTERNS
33
34
1. Allows to register already used test
data
2. Allows to avoid duplication of used
test data
PROBLEMS TO SOLVE
WHERE IS APPLICABLE:
Test data
35
PATTERNS:
OBJECT POOL
TYPE:
CREATIONAL
36
PATTERNS:
OBJECT POOL
TYPE:
CREATIONAL
37
1. Enable data driven approach for
your test automation project
PROBLEMS TO SOLVE
WHERE IS APPLICABLE:
Test data
38
PATTERNS:
DATA PROVIDER
39
1. Allows to operate by objects
2. Reflects business logic
3. Make tests more readable
PROBLEMS TO SOLVE
WHERE IS APPLICABLE:
Test data
40
PATTERNS:
VALUE OBJECT
-
Data Access Object
(DAO)
TYPE:
STRUCTURAL
I
41
USE PATTERNS
WHEN YOU
HAVE PROBLEMS
TO SOLVE
And your team will be open for any help you need
https://github.com/tatarynov/patterns-demo
42
I
43
QA DAYS
COMMUNITY
https://www.meetup.com/qa-days/
44
Q&A
45

Test automation design patterns