Test Automation Framework Guide
A software framework is used for developing software applications. In most cases, a framework is a platform configured for specific environmental requirements which provides a foundation where software developers can build programs for that specific platform. A typical framework consists of a set of coding standards, protocols, rules, and guidelines that help developers build an application. A test automation framework has the same purpose in general, but for testing software rather than creating it.
What is a test automation framework?
As described above, a test framework is a set of standards, protocols, rules, and guidelines. In a test automation framework, these elements are used to increase code reuse, higher portability, reduce script maintenance, save costs, and more.
When testers are working on different modules of the same application, and want to avoid a situation where each developer has a different style of testing and fixing bugs, the test automation framework is the perfect solution. Like that, you will have a team following the same steps and using the same set of rules and guidelines that are perfectly tailored for your needs.
NB: A test framework should be always independent of any application so it can be used with any AUT. This means that a test framework should be scalable enough so it can cover the requirements of every application to be tested with it.
While setting up a test automation framework, consider these questions:
- What methods will be used? How reliable are they?
- Could you make testing faster in any way?
- Could you easily recreate or reuse a code sample?
- Could you make anything easier than it is right now?
Once you have the answers to those questions and all others that are applicable in your case, you could start writing the guidelines for your test automation framework.
Why is the test automation framework important?
Test automation has become a fundamental part of the agile type of working especially for continuous integration, test-driven development and behavior-driven development. Using an automation framework could help you while executing the following types of testing:
- Unit testing
- Functional requirement testing
- Performance testing
- GUI (graphical user interface) testing
- Regression testing
- Integration testing
- System load testing
- Security testing
The main benefits of using a test automation framework are:
Better scalability and modularity
The better scalability will allow you to use one framework for different types of applications that you need to test because you can always adjust it to match your needs perfectly. Executing tests only on different modules is always easier for testers because there is no need to execute only one big test case but few smaller ones instead. You can set them to have maximum test coverage easily using a modular testing framework.
Better process definition and understandability
If you have a unified process for executing tests and good documentation, your team will be ready to test any application you give to them. Also, this is helpful when you have a new person starting on your team – they will understand better where their work fits and how to collaborate the best with the others in your team. Especially in agile teams, the process definition is essential.
Ease of coding and re-usability
Every framework comes with a code database which is the biggest advantage when you are using test automation. Every valuable test can be saved for future needs and can be always reused. This saves time and makes coding easier because there is no need to do everything manually anymore. In the end, you can have a big code database that can be used for any AUT with just small adjustments.
Maintenance and cost
Once the maximum code coverage is achieved there is very little need for manual intervention to run automated tests. New test cases with slight modifications of data can be developed at a reasonably low cost because of the already established code database and rules in the framework. Also since the codes can be reused multiple times the time of building test cases is lower and the maintenance easier.
Types of automated testing frameworks
There are seven common types of test automation frameworks. Each of them is used for different purposes and because of this is important to know which one is the best for your needs. To help you choose the right one for you, below you can find explanations for each type with their particular advantages and disadvantages.
Linear Automation Framework
As the name suggests here all the steps are written and executed in sequential order. This type is also sometimes referred to as record-and-playback. The tester is recording each step and then plays the script automatically to conduct the test. This is the best type of framework for small functions and applications or when you don’t have a lot of time for performing the test.
Ranorex Recorder is the perfect tool for a testing framework using linear automation as a type of testing.
The best advantage of this type of automation framework is that there is no need to write complicated custom code. And this is the best way to generate test scripts fastly because the recording is not taking as much time as coding.
The linear automation framework is one of the easiest to follow because of the sequential manner in which it is recorded.
In most cases, the data you are using for such tests is hardcoded into the test cases and this would mean that the test case is not reusable because you cannot rerun it with multiple sets of data.
If anything changes in the application that type of framework will need a lot of rework and therefore the maintenance is harder.
Modular Based Testing Framework
The modular framework will require the tester to divide the application into different units, functions, or sections based on some criteria and to test them separately. Once the app is separated into the modules the tester decided, they will create a test script for each of those parts and put them in a one larger text script in a hierarchical order. These test case sets can be reused for other test cases as well.
The important thing in a modular framework is to build your modules in a way that the change in one module won’t affect the other ones.
In this type of framework if changes are made to some part of the application then only the module responsible for this part of the application should be modified.
Another advantage is that modules can be reused easily without the need to fix the whole test case. Because of the high level of modularization, the maintenance is easier and cost-efficient.
In modular automated frameworks, the data is still hardcoded into the scripts, so you can’t still use multiple data sets.
Coding is required to set up the framework because it is not based only on recording.
Library Architecture Testing Framework
The library architecture framework is based on the modular framework but there are some differences. For example, instead of creating different modules and having different scripts for each one, the tester identifies similar tasks in the scripts and groups them in functions. In this way, the AUT is broken down into common objectives. All those common functions are kept in a library and they can be used every time when they are needed.
The advantages are similar to the modular framework since the library architecture framework is basically the same. This type of framework is easier to maintain and offers great scalability. Of course, it is cost-effective as well.
The option for reusability is higher here as well, because of the library of common functions.
Again the data is hardcoded in the scripts and the functions, so any changes must be done directly with the scripts.
It could take more time to find common functions and build the library. To do this, it’s also necessary to have more technical knowledge and experience.
The focus of this type of framework is the data. A data-driven framework separates the data from the scripts and their logic and stores it externally. This is perfect for cases when the testers should test the same feature or functions regularly but with different sets of data. For this reason, the data is not hard-coded in the scripts as in the previous types of frameworks.
A data-driven framework allows testers to use external data sources such as Excel, CSV, SQL, ODBC repositories, text files, etc. When the scripts are connected to the data source, they will read and populate the data where necessary.
The main advantage of a data-driven framework is the possibility to use multiple data sets. Scenarios can be tested with data that varies, reducing the number of scripts needed. Often, data-driven tests can be executed faster than tests in other types of frameworks.
To build such a framework, you will need an experienced tester, preferably proficient with multiple programming languages. This is because the identification and the formatting of an external data source and the creation of the code/functions should work perfectly so the data can be replaced with the right variables in the right place.
Another disadvantage is that setting up a data-driven framework takes a longer amount of time.
Similar to the data-driven framework, in a keyword-driven framework, the functions of the AUT are put in a table with instructions in consecutive order for the tests that are being run. The script logic is separate from the data.
In the external table, the keywords are stored in a step-by-step fashion with the object they are associated with or the UI element that they are being used on. This way the object repository will be linked to the object to their associated actions. Those actions could be simple actions like clicks or complex like verifications. So the keyword is actually an action performed on a GUI component
Similar to the data-driven framework, once the table is set up for the keyword-driven framework, all scripts should be written in a way that prompts for the necessary actions associated with this keyword. So when a test is run the data that is read is pointing to the keyword that is executing the needed script.
In a keyword-driven framework, it is not necessary to have strong scripting knowledge. One keyword can be used for multiple test scripts, so this makes the script reusable — one of the most important benefits of a testing framework.
Unlike most of the types of frameworks, this one can be built with or without a specific application.
This type of framework is not as scalable as other types of automated testing frameworks because there is a constant need for maintenance. This is why you will need a tester with experience in building and maintaining the framework and the keywords tables.
Because of the reasons above, the starting price of setting up a keyword-driven framework could be quite pricey. It also takes more time to define the best keywords and map them to the right actions and have the libraries ready
Behavior Driven Development Framework
The behavior-driven development framework is easily understandable because it does not require the use of any programming language. This is the perfect framework for projects where a lot of teams are working together and some of the participants are not technical.
This type of framework has evolved from TDD (Test Driven Development) but it is written in a shared language, which improves communication between all teams working on the project. In TDD the tests are written before the code is created and it is the same in BDD as well.
This framework creates the possibility to work with multiple test data. Increasing the reusability of the code.
Because BDD is written in a simple language, it is easily understandable for the whole team and easier to teach to new team members
One of the disadvantages of BDD is that the documentation and all the requirements should be prepared with attention to detail because even a small miss could make BDD not effective enough.
Hybrid Testing Framework
Last but not least is the framework that can be a combination of any of the previous frameworks. A hybrid system can leverage the advantages of different frameworks and avoid some of the disadvantages.
Every team is different and the processes used are different as well. More and more teams are moving to the agile model and are setting up more flexible processes, and need a framework that is responsive to those processes. This is why a team may need to use a hybrid testing framework.
A common combination is a Keyword-driven framework and Modular testing framework or Library Architectural Framework. Of course, depending on the application and in the evolution of the project the framework could change as well.
You can combine the frameworks you need and benefit from their advantages. It is always easy to modify the framework to match your needs perfectly.
To build and combine a hybrid framework you will need an experienced tester that knows how to create the needed scripts and libraries.
The initial price could be higher since you are building a more complicated framework and the maintenance is not that easy because there are multiple components to take care of.
How to choose the right type of automation framework
The choice of a framework depends on an organization’s unique needs. There are also many testing tools that can be used and help you with the creation of your framework.
Before choosing a framework, have a clear plan of what you want to achieve with it. Answer questions like:
- Are you going to test only one app or you want a scalable framework adaptable to different apps?
- Do you need to make tests with variable data or is hard-coding data acceptable for you?
- Are only testers going to work with the framework? Or you need some other teams like Product to be involved?
- Do you have an experienced tester that can build the framework you need?
- Are you ready to pay a higher initial cost to build a framework that is more complicated but more effective for you?
There are other questions that may be unique to your situation and you should take all of them into consideration.
Test automation framework tools such as Ranorex offer free trials to help you identify which one meets your needs the best. There are also a lot of code samples or libraries that are ready to use: take advantage of that as well and avoid the need to do everything from scratch.