What Is an Automation Testing Framework? An automation framework is a common set of tools, guidelines, and principles for your tests. Having a framework helps to minimize test script maintenance. I like to break down an automation testing framework into specific areas of concern, or what I call the “four Ps” of an automation framework: people, planning, process, and performance. The first one is the people aspect of a test automation framework. People As we already covered earlier, you want to make sure that you have set the expectations of your managers and team about your automation strategy. To help ensure that your automation is collaborative and a whole team effort, I recommend that you include automation on your sprint team’s definition of done. The next stage is the planning piece of your automation framework. Planning Before writing one line of code, always check to see if there is an existing library or tool you can use before inventing your own. Break your automation framework into abstraction layers so that if anything changes, you just need to make the change in one place. Using established automation testing design patterns like the ones we cover later in this post should be part of the planning stage. Separating your tests from your framework will also help when you have to make changes to your framework. Also, plan on making your methods and utilities reusable to avoid code duplication. Making your test and code as readable as possible (they should read like English) will go a long way to prevent confusion and code duplication. Finally, when planning your test, it's important to be aware of what test data your tests need. Many times, tests run against different environments that might not have the data you expect, so make sure to have a test data management strategy in place. Including support for mocking and stubbing in your framework can also help with some test data issues. Process Having a process in place that holds team members accountable for automation is another vital piece of a framework. Since automation is just like any other development project, make sure to use the same process and best practices that developers already follow, like using version control and performing code reviews on all automated tests. Performance Always start your automation framework with the end in mind. Tests need to be reliable and maintainable. They also should run as fast as possible. Along these lines, make sure that your developers are creating unique IDs for each element that you will have to interact with within your tests. Doing this will help you avoid resorting to lousy automation practices like relying on a coordinate-based way to communicate with an element. Another top killer of test automation script performance is the failure to use proper synchronization/wait points in your tests. Too many hard-coded waits will slow down your test suite. Use the preferred explicit wait method for synchronization. As you write your test scripts, think about how they would perform if you had to run in parallel. Thinking about possible parallel issues beforehand will avoid problems when you start to scale the running of your test suite again on a grid or a cloud-based service like Sauce Labs. To ensure that your tests are as preformatted as possible, refactor slow or poorly written code whenever possible. Including reporting and logging in your framework will help you quickly identify poorly running code. To make sure that teams follow all these guidelines, determine a strategy for training and retraining your framework users. That’s not all …
|