5 common mistakes in test automation and their mitigation
While one would say that every SDET’s main task is making developers cry, an informed person would know that it happens only every so often and that they actually come with useful pieces of advice and not just bug reports.
Test automation has become one of the essential approaches in today's software development lifecycles. The benefits which test automation brings are known to everyone and therefore, the interest in implementing it in the development flow is only increasing. As a result, organizations are striving to achieve zero manual testing and in-sprint automation. However, trying to introduce automation as soon as possible in a project without some real strategic planning can lead to making mistakes. In the following few sections, the most common automation mistakes will be shown as well as their potential mitigation to prevent them from creating a snowball effect on the team’s effort.
Mistake 1: starting without a plan
Like all in life, automation needs to start with some proper planning, especially in more complex projects such as banking software development projects. Before writing the first line of the test automation solution, you need to formalize and prioritize the test scope and specify the goals of automation. In the same way as an application’s development won’t start without a proper functional specification document, you shouldn't start an automation solution without listing the requirements first. To prepare for the automation project ahead of you, you need to define a goal, and decide about the layers you want to automate and the tool selection. While deciding about the tool, don’t fall into the pitfall of open source but actually seek a tool that will resolve the problems you have.
Mistake 2: taking hasty shortcuts
Once you feel comfortable with the automation requirement document and the scope defined in it, you are ready to move into the design and development phase. As we all know, the development team is under enormous pressure to implement and deliver features as fast as possible. Unfortunately, this leads to developers taking shortcuts with their test automation.
Some of these imprudent shortcuts are:
- not following the best coding practices
- no review process
- low code reusability
While writing test code, the main focus should be on keeping the code maintainable and debuggable. Often we overlook that the test code is a development project the same way as a software project is and with time, we will need to come back and update it. And when that day comes and you start working again on those areas you rushed through with the shortcuts, you’ll see that the time spent on improving and getting back to speed overshadows the time you saved while making them. Almost every developer and tester who worked with test automation have encountered this in their career at least once.
While implementing, try to incorporate an efficient logging mechanism to specify successfully done steps and errors to ensure that no functional is left without exception handling. In this way, errors in the framework can be traced and troubleshot without even looking at the code itself.
Mistake 3: multiple developers crisscrossing one code
The best coding practices are not the only ones that should be considered in the development phase. You need to implement a good branching and release management strategy. Often multiple developers work together on a code which can lead to code conflicts due to the code being potentially unstructured. Implementing a branching strategy from the beginning and enforcing it on the automation developers will lead to faster release management and easier distribution of the automation framework throughout the project and test cases.
Mistake 4: automating a larger flow into one test script
While most organizations consider branching strategies and coding practices, they often fail in the area of managing their test data and managing their automation flows.
When developers start to automate the E2E (i.e., end to end) flows in the application under test, they often decide to automate a larger flow into one test script. This is considered one of the common automation mistakes because it can lead to a test script failing due to a small failure and not every aspect of the functionality being checked. Automation developers should divide larger application flows into smaller testable granular flows. Such division will increase the stability of the test execution and improve the pass rate as well as better specifying failure points. When the application flows are divided into smaller ones, automation developers can easily do proper validation testing and increase the testing coverage.
Mistake 5: having no strategies regarding Test Data management
Poor test data management is one of the leading causes of automation failures. For instance, using the wrong source to store data can lead to making automation execution slow. One of the good practices is to store and retrieve data from JSON or XML which are considered lighter forms of data sources in comparison to CSV and Excel. Once you determine the right data source, you should try to externalize your test data so that you are able to change it easily for future maintenance. Also, test data should be managed for multiple environments because this makes creating and managing files more efficient, easier and specific. For example, you can divide your test data for environments into 2 main categories - common data and specific data. Common data is data that would be common for all environments, while specific data is data that changes according to the environment. Finally, before or after a test run, make sure to reset the test data state (a must when dealing with E2E tests) so that you can be sure that the test failure isn’t caused by it. Resetting the test data stated for the specific data required ultimately leads to improved repeatability and predictability of automated tests.
Once all this is considered and integrated into the development flow, you need to allocate time and resources to frequently update and enhance the automation framework and test cases and include them in regular runs.
A few pieces of advice
An automation framework is just as complex a system as a business application but most organizations think of it as a “set it and forget it” part of the development cycle. Most mistakes mentioned above happen because organizations don’t place the same importance on automation development which leads to not following best practices and creating a lot of technical debt that makes the maintenance a lot harder than it needs to be.
The best and only solution to keep your test automation performance at its best is to address these problems as soon as possible. Frequent maintenance and good requirement analysis will help avoid long-term problems and help your organization keep up the speed with test automation and achieve the holy grail called “in-sprint” automation.
Your take on the subject
They say knowledge has power only if you pass it on - we hope our blog post gave you valuable insight.
If you want to share your opinion or learn more about how our software engineers in test go about automation, feel free to contact us. We'd love to hear what you have to say!