Before we start coding, it is important to think carefully about the underlining structure (architecture) of the target framework. This will minimize the costs of framework development and maintenance of the automated test assets, so that they can easily be extended to cover new requirements.
The key activities we need to perform in order to design a robust test automation framework may include:
The components of a test automation framework comprise an array of modules that manage different requirements for automation. The main modules include a flow controller, a reporter/logger, and an exception handler. For simplicity, data loading is implemented here using the UFT native DataTable, but of course, other options, such as XML files or a DB, can be used.
We also use a command wrapper design pattern to implement reusable runnable components, which are direct replacements for the reusable UFT actions.
We will now list out the component design patterns.
The controller supports the following requirements:
A reusable component supports the following requirements:
Run
method to be implemented), which will execute the actual codeThe event handler supports the following requirements:
The custom reporter supports the following requirements:
To conclude this recipe, the basic design outlined here covers the basic needs of a test automation framework, namely, flow control, reporting, data loading and sharing, and event/exception handling. This design pattern also supports keyword-/data-driven flow control, and encourages the use of highly effective object-oriented design patterns. The next sections will describe in detail how to build each of these components.