Monday, October 7, 2019

Design Pattern in Automation Testing


Design Pattern in Automation Testing 


An automation testing design pattern is simply a solution that has shown to be successful again and again. These patterns also are considered best practices for any object-oriented programming development project.
It is always recommended to start using the best practices or design patterns right from the beginning to make the automation tests more repeatable and maintainable hence the software applications are keep on changing from time to time.
                           abagmar@gmail.com
Anand.Bagmar@thoughtworks.com
@BagmarAnand
about.me/anand.bagmar
THANK YOU
Advantages of using Patterns for Test Automation

  1. It is well known and well understood.
  2. Tried and tested solutions for common problems.
  3. Reduces complexibility.
  4. It is a language neuttral
  5. It helps aid in communication


5 design patterns that can use in  automation testing(They are created to solve common problems in software design)

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.
This pattern also adheres to the software development practice the DRY principle (Don't Repeat Yourself).
The DRY principle basically means that each piece of logic should be coded once and only once. The duplicate code makes the code harder to maintain; the less code  write the better since more code to maintain means the greater chance the tester to have bugs to creep into their test framework.

This single software design pattern can easily solve the bulk of  testing problems, but it’s not a silver bullet. It will, however, help to take a huge leap forward in making the automated functional tests more stable.




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, it will simplify the API usage and the tester have control over how this external API is used and can prevent misunderstanding or misuse. 

Factory pattern


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

Singleton pattern


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

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. It can safely invoke methods on the null object without the threat of a NullReferenceException to break the application. 

Putting all together


Once the tester have gone through patterns one by one now it is time to put everything into one project.

No comments:

Post a Comment

WebService, API and their Difference

Web service (WS) A service offered by an electronic device to another electronic device, communicating with each other via the World W...