top of page

Automation Design Patterns

Design patterns very important to understand by any automation engineer as it helps build scale-able automation architecture. Basically design patterns are created to solve common problems in software design and now a days it start using for automation as well.

There are really sophisticated design patterns available to solve complex issues in software development. But also there are easy to understand and adopt design patterns that can significantly improve readability and maintainability of our test automation code.

5 Most popular design patterns used in automation are:

1. Page Objects Pattern

2. Facade Pattern

3. Factory Pattern

4. Singleton pattern

5. Null object pattern

Brief Information for every design pattern as below, for detailed explanation you can read Next Generation Automation other blogs specific to design pattern

1. Page Objects pattern

This is the most important pattern related to software automation. It enables you to create object repository with UI elements. Elements are separated from tests logic. This pattern makes code much more maintainable and reusable.

2. Facade pattern

The whole idea of facade design pattern is to provide simple and easy to use interface to a larger and more complex code, API or set of APIs. Most likely you don’t need everything provided by the API. So for ease and better maintainability, only API features that are needed gets exposed outside the facade. In this way, you simplify the API usage and you have control over how this external API is used and can prevent misunderstanding or misuse.

3. Factory pattern

Factory pattern is used to create objects based on specific rules. You may have several classes implementing an interface. In your code, you do not want to bother defining which concrete class to instantiate or you might not know what object is suitable to get instantiated. This is why you handle the object creation task to the factory which knows exactly what object to create. With factory pattern, object creation is encapsulated.

4. Singleton pattern

Singleton pattern is needed when you need exactly one object from a specific class in the whole application.

5. Null object pattern

The idea is to make code simpler and safe by skipping null reference checks. Null object implements given interface and its methods are doing nothing. This makes the null object predictable. You can safely invoke methods on the null object without the threat of a NullReferenceException to break your application.

Building better QA for tomorrow


bottom of page