Good practices to automate UI software tests
There are a lot of reasons to automate tests in a software. But in this article we are going to see which practices is important to follow when we need to automate tests.
When we need to automate tests, it’s necessary to think in a lot of things and answer some questions. For example, what language will I use in the test scripts? How will Iorganize the test cases and test scripts? Which test cases I need to automate? What technologies will I use, like TestComplete, Cucumber, Selenium? How to fit the tasks related in the team? There are a lot of questions! The goal of this article is to understand better wich practices we need to follow. But in other articles of my account I’ll answer these other articles.
A great choice: which technologies to use in your project
Once a colleage said a very interesting thing: “two same languages interact better with each other”. And it’s true. There are a lot of advantages to develop the test scripts in the same language than the software is develop. The project will have all the filles in the same language, you’ll can reuse some method and functions when you develop the tests. But sometimes it’s not possible. We cannot develop test scripts in every programming language, especially because some tools to automate test aren’t compatible with some languages. But languages as C#, Java, Python, and JavaScript are languages that are compatible to every tool to automate tests that I know.
The programming langue is not the only technology to choose. Generally is necessary to choose a framework (like Selenium, Cypress), choose some plataform of test automation, the standard language to write the scenarios, etc. Some tools are open source, and others is necessary to pay a license.
The framework to use will depends about the project. If it’s a desktop software, robot framework or TestComplete is recomended. TestComplete needs a license, and is very good to automate a great mass of tests. This tool also has some more features compared to robot framework. We can also use TestComplete with the Selenium framework. Some other advantages of TestComplete is that it works with desktop, web and mobile softwares. And is very common to work in a software that is not just web or desktop. But robot framework is good to automate desktop softwares too, and is open source. If you plan to automate a website, you can work with Seleniun and Cypress. Selenium is more used, and consequently it has more materials to search and consult at the internet. However it has many other features, not just tests. And Cypress was created focused to be a framework only to UI test automation.
Organize the test cases to automate
If you need to automate a test, you will need to follow a scenario. So first you need to organize some scenarios, and I reccomend to follow a sintax, like Gherkin, using the basic words Given, When and Then.
But begin in what part of the software? Start with the most important features. The goal to automate software tests are to ensure the security and stability of the software, so the most used routines, features, and also the most critical rotines that must be mathematically tested (like financial features).
Fit the tasks in your work environment
I worked in some companies that had test automation. In some companies, there were a team of 8 employees that were responsible to automate a software already developed. Some were responsible to develop the test scripts, to document the scenarios, to review the test scripts, the PO, etc. But other companies, specially small companies, it’s possible that just one person is responsible to automate the tests, and is responsible to do almost everything related, like to automate the tests, write the scenarios, manage the automation project, etc. Generally the companies start to automate the software when it is already developed, but the ideal scenario is to automate the software during the development process, and work together with the developers.
Integrate the automated tests with the CI/CD process
It doesn’t matter if you use Jenkins, Azure devops, etc. It’s very important to integrate everything that you automated to the CI/CD process, so the tests will be continuously executed, and identified the inconsistencies quickly.
Follow the same good practices as any other software project
Develop and work in the project as a software project for production, because the test automation project must run as a software. And the results and problems to face of not follow good practices, like the Design Patterns, SOLID, will be the very similar.