Design Patterns for Automation

Ali KAYA
4 min readMay 13, 2022

Welcome to my page again. I want to thank you guys for all your attention to those articles. Despite all the busy workdays I’m trying to share my experiences with you. If you want a lot of stars on your Github repo, If you want reusable scripts, and if you trying to improve yourself this article is amazing for you. Okay, here we go.

Why do we need to design before writing our test cases in Automation? Please remember SDLC(Software Development Lifecycle), even if it is used for different means, again. Even in STLC(Software Testing Lifecycle), test design is coming before the test execution phase. By designing a test case and test environment we can be sure how will execute our case. When we determine how to design test methods, we can perform effectively OOP(Object Oriented Programming) seeing that it enables easy test process management.

In order to create long-run automation and also make them better, design patterns provide a future vision, scalability, and sustainability to testers. Small-scale development firms commonly prefer to pass some of the STLC steps.

Design patterns present solutions that will you face while you are coding. While creating objects to prevent duplication we must take precautions. Which one will be parent class, which abstractions should we create, which methods do we need to encapsulate, etc. The whole script should be designed generally.

However no need to reinvent the wheel. Don’t waste your time trying something that someone else has created already. A lot of people have faced those challenges like that. Patterns are templates for solving design problems, which we can use while we create our software test solutions.

Let’s take a look at Erich Gamma, who is one of the writers of Design Patterns: Elements of Reusable Object-Oriented Software, he is one of the most famous developers all around the world, what does he say about our topic:

“ Each 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 way twice.”

Then, Let’s explore Automation Design patterns targets:

1. Designing and prioritizing objects and sets of test case structure: Firstly architect who is responsible for the test automation template should determine which type of design pattern is suitable for their test structure.

Secondly, determine which variables will protect against any changing. For instance, you need to decide whether you will have abstractions, interfaces, relations among classes, etc. After the planning phase, you need to design your project class architecture. Connections between classes should draw.

That page is from draw.io website that presents amazing templates for your design.
That page is from the draw.io website that presents amazing templates for your design.

2. Don’t repeat yourself: This matter is one of the clean code matters which we need to follow permanently as well as maintain efficient performance and code quality. To illustrate we can say that think of creating the same object in a lot of classes, you would see many “new” reserved words.

In terms of occupying place within the heap memory and breaking the readability of code, testers should be attentive to the design of test scenarios. In the test design step, people who are responsible for making test automation design patterns must determine which objects will be used in which class. We can think of it as the “BeforeAll or AfterAll” method.

We don’t need to write those methods for all classes, once you create a class like a parent class other classes can use them by doing “extends” reserve word.

3. Easy Maintenance: Maintenance is one of the most probable issues in software development and testing. In order to easily check a test package, we need to get it easily as well as read it without any structural precaution. Even so, seniors can solve it at the end of the day, it takes a lot of time. Despite all emails, hard tasks, and time pressure nobody can spend their time knowing your spaghetti code. Time is money in the software industry like in other industries.

Thanks to suitable design patterns, no one has live time troubles and they can begin to fix your project. Therefore, each programmer and tester must be attentive in terms of structural and design kinds of stuff in projects.

4. Sustainable test scenarios: That statement has a connection with the future vision. A project is not considered short-term. A firm or project management may want new attributes in changing circumstances along with changing technology or user mindset. While the world change, you must follow innovations. One of changing is environment changes, firms can select another IDE, another tool, or framework when you take those radical decisions you must orientate a new section in your team.

With complex and hard-to-read projects and coding structures, you can not pass new useful tools or frameworks. Those firms who don’t care about sustainability can be afraid of any change. They wouldn’t like to be innovative conversely their way would be overprotective in terms of programming and testing. However, teams who follow design patterns can change themselves immediately. To catch new technologies you must be flexible on the grounds that the software world is growing up rapidly.

Thank you for giving your time, I hope this article gives new perspectives to your mind. Please keep following me, Ima explain one of the Design Patterns in the next articles.

Sincerely.

--

--

Ali KAYA

Assistant Software QA at Nesine.com. Quality Assurance, researcher, debater. Love the world, love the animals.