Automation Framework

7 Best Practices in Automation Framework

In this writeup, we are discussing about automation, its framework, and 7 best practices in automation framework.

Let’s start.


Automation is the use of technology to perform tasks with minimal human work. In case of automation testing, we use automation tools to develop scripts for testing a software application.

When we run the script, it will execute the code in the script and perform testing of the application automatically based on the code. In this way, we can test the application without the need of manual testing.

Automation Framework

In order to arrange our automation scripts in a structural manner, automation frameworks are used. This structural arrangement of our automation scripts makes the code readable, understandable, reusable and maintainable.

So, it is important to follow automation framework when developing an automation project. Moreover there are some best practices that you can follow in the automation framework, which makes the automation project one of the best in terms of quality.

Best Practices for Automation Framework

The best practices that can be used in automation framework are

  1. Using design patterns
  2. Independent test cases
  3. Make the test automation framework portable
  4. Use data driven instead of repeated tests
  5. Name the tests wisely
  6. Consider using an BDD framework
  7. Use soft assertions

Using design patterns

Design pattern is a reusable solution for a common problem in software design. Each design pattern is a particular example of a specific solution for a specific problem regardless of the programming language or paradigm.

One of the important design patterns we can use in our automation project is the “Page Object Model”. As the name suggests, Page Object Model represents all locators in a web page in the form of an object.

The main idea behind such an object representation of a web page is that it helps in reusability. It means we can use the same object to call the locators of a page in our test cases.

It also helps in removing code duplication because we don’t need to invoke the locator’s path in our test cases. Instead of that we just need to use the object to invoke the locators.

Also this helps in improving the code readability and makes the code easy to understand. This design pattern is very popular and can be implemented in all automation tools like Selenium, Cypress, PlayWright etc.

Independent test cases

We used to write multiple test cases in a test suite. It is important that each and every test case should not be dependent on each other and it should be independent.

The reason behind this is that when one test case fails then it will not make other test cases fail since each and every test case is independent. This helps in reducing the failed test cases count and increases the regression pass percentage during regression run.

The reduction in test cases failure count will make the life of QA easier because they will have less number of scripts to analyze for any bugs.

Make the test automation framework portable

Many automation frameworks require huge efforts to run them on another machine, unlike the one which was used for framework creation. This is a very bad practice because it doesn’t allow new team members to run tests easily. 

Additionally, if we want to run tests on the CI server, it would be a very tricky task if the UI test automation framework is not portable. Thus, making the test automation portable is very important.

If we have test automation files that are required for test execution, they should be attached to the framework instead of storing it on a local machine. However, if they are relatively small, we can store them under the control version along with the framework itself.

If they are big, then use any external storage like Amazon S3 or any other cloud storage. After that, implement a mechanism that downloads these files to the right locations during the first test executions, if the files are not there yet.

Use data driven instead of repeated tests

In a data driven framework we store different combinations of data that are needed as inputs for testing in a separate file. If needed, you can reuse this stored data in multiple test cases. It is very useful in testing different scenarios of functionality in application.

We can also store the different combinations of output data we get for different combinations of input data for a particular functionality. The main advantage of this data driven framework is that it reduces code duplication and increases code reusability and readability.

Name your tests wisely

Test names should be very clear and should provide a self-descriptive idea about which functionality is being tested by using this test. It’s because you need to understand what each test verifies even a year after you wrote the test.

Consider using an BDD framework

BDD is a software development methodology in which software is implemented in a way that its behavior is described. It can be applied for any type of testing including unit tests, component, integration as well as for many other testing types. 

UI testing is one of main areas where BDD can be applied with great success. BDD is recommended in UI automation for many reasons.

First of all, BDD is a methodology that helps teams understand each other, and create strong outside and inside team collaboration. By writing our tests with BDD, you create specifications that can help your team understand tests and requirements much better.

This means that along with writing tests, you are creating a clear test documentation. This ensures that we don’t waste other team members’ time (who might work on our tests later), as well as our own time. It’s because we don’t need to explain and help with such tests if they are unclear.

Second,  BDD helps the Business side (e.g.Test and Project managers) also understand these tests. This brings additional value to testing as they will make recommendations based on business benefits.

Third, BDD usually forces us to follow a strict code organization pattern, which helps in avoiding code duplication. This is done by having separate components called steps or actions that will be the building blocks for our tests.

Use soft assertions

Assertions are designed in a way that makes tests fail if the assertion fails. However, in UI automation, you might have to verify several things in a row. Let’s assume that you have several UI elements to verify and two of them have some unexpected values.

With classic assertions, after test execution, you would notice only one error, after which the test would fail. This means that our test was successful and caught a bug. However, it won’t identify the second issue as the test execution stopped at first failure.

To overcome this issue, soft assertions are a good option. With this, the test execution flow will continue even if any one assertion fails. At the end, it will sum up and showcase the list of failed assertions.


The practices mentioned above when applied in an automation framework makes it a good quality code. It will also provide numerous benefits like readability, reusability, reliability and maintainability.

Are you looking forward to a hire a professional Software Testing Company?

If yes, then contact us. Perfomatix is one of the top AngularJS development  company. We provide angular development services in developing highly scalable software solutions.

For more clarification about us, visit our success stories section to find out more about some of the startups which made it big with us.

Perfomatix | Product Engineering Services Company