Test Automation Best Practices: Deciding What and When to Automate
Tags: testing, womenintech
Published: 2020-10-26 19:10:09

Test automation is generally introduced into a project to solve issues such as repetitive manual work, working with large data sets, or getting faster feedback in a CI/CD pipeline. With this buzz around test automation, you may be considering going forth and automating "all the things." You may have selected the testing framework and the team that would do the test automation. But have you seriously considered what you should automate or how feasible it is for you to automate everything?

Exhaustive testing is impossible. This is one of the key principles of software testing. While test automation significantly expands test scope and coverage, automating EVERY test takes more cost, effort, and time than is practical. Before any test automation begins, it is imperative for you to make a data-driven decision on what you will and will not automate --- and in what priority. When deciding what to automate, there are some basic items to consider, such as the automated test level at which you will be creating your tests. Automated Tests can be placed into three main levels: [Unit Tests, Service/API Layer Tests, and User Interface Tests](https://www.browserstack.com/guide/testing-pyramid-for-test-automation); you should evaluate the [pros and cons of writing tests at each of these different levels](http://www.agilenutshell.com/episodes/41-testing-pyramid) before proceeding.

Regardless of which level of automated testing you perform, the objective should be to automate what brings the most value and impact, areas always tested for every release, and areas hard to test manually. You should also look at areas where there are huge amounts of data to be processed. All of these factors must be considered before automating. If you create automated tests blindly or on a whim, it increases the likelihood you will not get as much value from it as you should.

Detailed below are five (5) critical areas/factors to be aware of as you consider integrating automated testing into your current workflow.

Automate your smoke tests.
==========================

![Smoke Alarm - Automate Your Smoke Tests](https://dev-to-uploads.s3.amazonaws.com/i/xq4lu8ddqxodue6j5s4w.jpeg)

Ensuring that your application functions on a basic level is very important and should be done after each change or when a new build is made. This can be integrated into a CI/CD pipeline in order to verify that show-stopping bugs are caught early. [Smoke tests ensure that the most important aspects and basic components of an application are functioning correctly.](https://www.functionize.com/blog/top-4-benefits-of-smoke-testing-and-how-to-automate/) They test areas that always need to work and can help you decide whether a build or application is stable enough to proceed with further testing. Automating your smoke tests can:

1.  Help to quickly detect show-stopping bugs early, such as app/webpage not loading, user unable to login, user not able to create an account, or payment services being down.
2.  Enable faster troubleshooting of new and regression bugs. Smoke tests by nature have high coverage and shallow depth. This results in a wide variety of test cases being tested without going too deeply into the application. Once these critical areas are working, it allows you to go deeper into the application to test other features.
3.  Result in [less manual interaction and be time-saving.](http://allselenium.info/importance-and-benefits-of-smoke-test-automation/) By integrating your automated tests into your Continuous Integration/Continuous Delivery (CI/CD) pipeline, your smoke tests are tested before a build is completed. This means that a build is not given to QA unless those smoke automated tests pass.

Automate tests that are always run, such as [regression tests](https://www.katalon.com/resources-center/blog/regression-testing/) or tests always found at the beginning of every workflow.
===========================================================================================================================================================================================

![Man running - automate tests that are always run](https://dev-to-uploads.s3.amazonaws.com/i/zc8ghx8rtoefy9s33ehs.png)

This allows you to have a set of stable tests vital to the application. For example, creating a user account would need to be done before the user can login and view the dashboard, make payments, etc. By creating an automated regression suite, you can:

1.  Run tests that quickly identify any bugs resulting from changes in the software. These changes may be new features or defect fixes.
2.  [Have a set of stable tests](https://testlio.com/blog/regression-testing-automated/). Regression tests are normally for existing functionality, which means these functionalities are not new and have been tested multiple times. This prevents flaky automation tests, and you then must spend a lot of time manually testing since you are unsure whether the tests really failed or not.
3.  Save time since you can now focus your manual testing efforts on more edge cases.

Automate extensive tests
========================
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ic870228oq4bbj8tzhcw.png)

Exhaustive tests such as inputting large sets of data, testing a form, or tests requiring the tester to do the same workflow multiple times but with a wide variety of data should be automated. You can create data-driven automated tests that can result in time being saved. For forms, automation allows you to quickly test different combinations of inputs to the form, such as whether fields are missing, incomplete, etc. Data-driven testing is very beneficial as it allows you to only [modify the data instead of the test script to get different results.](https://www.testing-whiz.com/blog/significance-of-data-driven-automation-testing) It is also very reusable and efficient.

Automate tests that require multiple configurations
===================================================

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/wat25aywr4p5m570p92a.png)

This could include tests on different Operating Systems(OS) and Browser Combinations. This can be tedious to do manually and, if automated, can help save time. Automated tests can be run on different environments (such as Dev, QA, Staging, Integration, or PROD) by simply [changing the environment variable](https://github.com/mochajs/mocha/wiki/HOW-TO:-use-environment-variables). Tests can also be run in parallel, which reduces the time needed for execution. You can use different CI tools such as [CircleCI](https://circleci.com/docs/2.0/parallelism-faster-jobs/) to specify the OS, browser, and environments on which you want the parallel tests to be run. Ensure that you follow [best practices when creating parallel tests](https://bitbar.com/blog/parallel-testing-what-it-is-and-why-you-should-adopt-it/) in order to get as much benefit from these tests as possible.

Automate your performance tests.
================================

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/yefjmz299jeotxbzpa5q.jpg)

This lets you [avoid launch failures, bad user experiences, and performance regressions.](https://k6.io/docs/testing-guides/automated-performance-testing) Performance testing checks how the system performs under load and stress and also identifies bottlenecks. [It checks the speed, response time, reliability, resource usage, and scalability of a software program under their expected workload](https://www.guru99.com/performance-testing.html). Automation can help you easily generate thousands of users to see how the application will respond. For example, Fandango is one of America's largest ticketing sites (with up to 36 million monthly movie-goers purchasing tickets from their site), and they wanted to ensure they were prepared for the movie *Star Wars: The Last Jedi*. They wanted to find out what their peak performance was and how to identify bottlenecks. [QualityWorks automated their performance tests and provided them with reports that would help to identify bottlenecks](https://blog.qualityworkscg.com/performance-testing-for-major-movie-release/) and, as a result, they had a successful movie sale launch. This is something they can continue to use to ensure the performance of their website is up to a certain standard.

Your Next Step
==============

This list of considerations is not exhaustive by any means but is a great starting point if you're considering how to integrate automation into your current QA workflow. Be strategic and focused in your approach. Sit with your current QA to discuss their current practices and to identify bottlenecks in their process that could be resolved with automation. Automating "all the things" is never the answer. Remember, before creating automated tests, think about the level you want to automate. Then, decide what tests you want to automate that would bring the most ROI for you and your team --- those that are repetitive, time-consuming, not flaky, critical to the business, or that test the performance of the application.

.........

About the Author

Julia is a Lead QA Consultant at QualityWorks with expertise in manual, automated, and API testing and training. She is passionate about sharing her knowledge and experience and contributes to the testing community through writing articles, and delivering testing content on [Test Automation University](https://testautomationu.applitools.com/webdriverio-tutorial/) as well as her [Youtube Channel](https://www.youtube.com/juliapottinger) and [blog](https://juliapottinger.com/). She also conducts testing Bootcamps for persons interested in entering the field of QA.

...........................................................................................................

Looking for ways to accelerate your testing process with automation? Reach out to our testing team at [www.qualityworkscg.com](http://www.qualityworkscg.com/)