Long-term maintenance is a critical factor in a viable test automation strategy. Test automation suites require maintenance because an application under test isn't static. Software teams continuously update and enhance app components and add new features.
Test automation runs software through scripted actions to verify that it is fit to deploy to production. If the test automation suite is not maintained, it cannot be reused, and reusability is the key to cost-effectiveness.
To develop a test automation maintenance process that can be sustained, involve more people. It cannot rely on just the people who set up the testing.
Plan for test maintenance
First, design test automation with maintenance in mind. Adhere to coding best practices, such as creating scripts that are atomic and autonomous. Atomic test scripts contain only one test, not an entire workflow. Autonomous test scripts run independently of each other so that, if one fails, it does not block the rest of the suite.
Make the automated scripts as simple as possible. Use annotations, such as @BeforeTest. This increases the efficiency and effectiveness of the test suite, and it also provides clarity to colleagues who were not involved with writing the scripts but will play a role in the test automation maintenance tasks.
Share that test automation knowledge
A second important aspect of test automation maintenance is the strategy for knowledge management. This is often overlooked, especially when the test team is made up of test analysts and engineers or software developers in test (SDETs). Especially in teams where only one or two people manage automation, knowledge management and transfer are critical. The test automation authors shouldn't be the only people able to maintain that automation. Inevitably, those test engineers will move on to other things or leave the team.
To create a knowledge management strategy, begin with documentation and version control, which we'll cover in-depth in the next section. Just like any piece of code, test automation code should get documented with notes explaining what each piece does. Encourage code reviews and expect other engineers to be able to update the scripts.
Lock in version control for maintenance
If your organization does not currently use a version control tool, add this to your knowledge management strategy research. Test automation is scripts that change over time. So, version control is critical to test automation maintenance. It ensures that, when maintenance is needed, an engineer can easily determine which version should be updated.
Version control is best managed using tools designed for this purpose. Many tools are available, both open source and commercial. There are centralized and decentralized open source version control systems, namely Subversion (called SVN) and Git. Additionally, vendors offer commercial tools, such as Perforce, Microsoft's GitHub, Atlassian BitBucket and cloud services such as AWS CodeCommit.
Git is an open source decentralized version control technology that tracks changes to code as developers make them. Git is especially useful when more than one SDET or test engineer works on the code. Also, having more than one SDET involved promotes knowledge and understanding of the automation code across the whole team.
Apache SVN is a tool through which a set of files and directories are combined into a centralized database to create an ongoing history of the code.
As soon as the scripts are created and proceed to code review, automation code maintenance begins. During code reviews, both SDETs and test analysts should review the code to ensure that it follows best practices and is understandable enough for others to maintain. More importantly, it gives other team members an opportunity to understand how the scripts were coded. In addition, this approach encourages collaboration, especially the type that results in more efficient and effective test suites.
Use the test suite -- a lot
The final step is to ensure that the automated test suites get used as much as possible. Share them not only within your team, but also with any team that can get some value from them. Plan to run the test suites for as many types of testing as possible. Can developers use them for unit or component testing? Perhaps the tests can be incorporated into an end-to-end system test.
Frequent use not only increases ROI for test automation suites, but it also increases the number of engineers, developers and analysts who are familiar with them.
An effective test automation maintenance process should always include coding with maintenance in mind and a way to centralize and disseminate test automation knowledge. Promote a team culture in which all members contribute to the test automation suite -- whether they code, review or execute the test scripts.