Guidelines For Automation Framework Design
A Framework defines a set of guidelines for all phases of test automation: Requirement Analysis, Script Design, Execution, Reporting and maintenance. A framework can be a wrapper around some complex internal architecture which makes it easy to use for the end user. It also enforces a set of standards for implementation
There is no standard set of guidelines available on developing a framework and what all considerations need to be taken during the development of the same. There are different white papers which go over types of framework and how they work. But none of them defines what all factors go in to the design of the same
This paper covers different aspect of a framework and key features it needs to have based on the requirements.
- Selection of a framework – Different types of frameworks that exist are:
o Data Driven framework – Used when flow of the application remains constant, only the data changes. The data is provided by external medium e.g. – excel sheet, XML etc…
o Keyword driven framework – This framework provides generic keywords that can be used with any type of application. It also provides abstraction from the type of automation tool used and type of being application tested, e.g. – it can test a similar Web and Windows application with the same test case
o Hybrid framework – A hybrid framework is the one which takes advantages from both Data Driven and keyword driven frameworks. These frameworks do not implement generic keywords but implement business logic keywords based on the application being tested. For ex – Login, Logout could be application specific keyword that can be used.
Don’t reinvent the wheel – A framework should try and use the power of the automation tool rather than re-defining the whole language by implementing new keywords. Developing a keyword driven framework is time consuming and costly. A Hybrid framework can be developed in a shorter time period and with less cost.
Reusability -The framework should allow highest possible reusability. Combining individual actions into business logic provides re-usability. E.g. – Combing actions like “Enter username”, “Enter password” and “Click Login” into one re-usable component “Login”
Support of different application versions -A framework should allow re-use of baselines scripts in case different versions/flavors of an applications are to be tested. There are two different ways to support different applications
o Copy and Modify – This method involves creating copies of the baseline scripts and modifying them for a specific application version
o Re-use and Upgrade – This method involves re-using baseline script and providing a upgrade code for specific version of application. This ensures maximum re-usability and should be preferred.
Support of script versioning – Scripts should be stored in a version control system like CVS, Microsoft® VSS etc…This ensures recovery from any disaster.
Different environment for development and production – Automation should be considered as any other development project. Test scripts should be created and debugged in Test environment. Once tested then only should be deployed to the production environment. This holds true for any emergency releases also
Externally Configurable – Configurable items of a script should be kept in an external file. This would contain configuration like Application URL, version, path etc…This allows running the same script against different environment. Ensure that location of the configuration file is not hard coded. Hard coded files would allow running on any environment but only one at a time. Keeping the configuration relative to current test path allows overcoming this limitation
Self configurable – Ideally a framework should be self configurable. Once deployed to a system, no manual configuration changes should be required and scripts should automatically configure the required settings
Minimal changes required for any object changes -Most common issues faced during automation are object identification changes. Framework should be able to patch such changes easily. This can be achieved by storing all object identification settings at a shared location. This could be an external XML file, excel file, database or automation proprietary format. There are two possible way to load this object identification configuration
o Static – In this all the object definitions are loaded into the memory at the start of the test. Any changes made to object definition can only be loaded by stopping and re-running the test
o Dynamic –Object definition is pulled as per request. This approach is a bit slow as compared to the static one. But in case of huge scripts where the fix needs to be made at run-time this is suitable.
- Execution – Framework might need to cater to below requirements (on need bases)
o Execution of a individual test case
o Execution of a test batch (combination of tests)
o Re-execution of only failed test cases
o Execution of a test case/test batch based on result of another test case/test batch
There could be many other needs based on the project requirement. A framework might not implement all of them, but should be flexible enough to accommodate such requirements in future
Status monitoring – A framework should allow monitoring the execution status in real time and should be capable of sending alerts in case of failure. This ensures quick turnaround time in event of a failure
Reporting – Different applications have different reporting needs. Some require combined results for a test batch and some require individual level test report for each test case in test batch. The framework should be flexible enough to generate required reports
Minimum dependency on Automation tool for changes – Some fixes can only be made by opening the script in the automation tool and then saving it. Scripts should be developed in such a way that modification is possible even without the unavailability of the automation tool. This deflates company cost by reducing the number of licenses required. It also allows anyone to make changes to the script without having the need to setup the tool
Easy debugging -Debugging takes a lot of time during automation and hence special care needs to be taken for this part. Keyword driven frameworks which use external data source (like a excel spread sheet) to read scripts keywords and process the same are difficult to debug.
Logging – Log generation is important part of execution. It is very important to generate debug information at various points in a test case. This information can help find problem area quickly and reduce the time to make a fix at the same time
Easy to Use – The framework should be easy to learn and use. It is time consuming and costly to train a resource on a framework. A well documented framework is easier to understand and implement
Flexible – Framework should be flexible enough to accommodate any enhancements without impacting existing test cases
Performance impacts – A framework should also consider the performance impacts of the implementation. A complex framework which increases the load time or execution time of scripts is never desirable. Techniques like caching, compiling all code into single library while execution etc… should be used to improve performance whenever possible
Framework Support Tools – External Tools can be developed to perform tasks that help in framework design. Some example tasks would be
o Uploading scripts from local folder to HP Quality Center
o Associating library files to currently open scripts
o Synchronizing local files with HP Quality Center.
- Coding Standards – Coding standards ensures scripts that are consistent, readable and easily maintainable. Coding standard should define all the below listed things
o Naming convention for variables, subs, functions, file names, script names etc… Ex – i_VarName for interger, fn_i_FuncName for function returning interger
o Library, subs, functions comment header. This should include information like version history, created by, last modified by, last modified date, description, parameters, example
o Object naming conventions. Ex – txt_FieldName for a text box
Automation should be considered as a development project and not just record and playback of events. Starting automated testing with a good framework ensures low maintenance. Guidelines discussed in this paper can be used as input for developing requirements for a framework.
Search following on GOOGLE to get ready to use selenium framework
InfoStretch Selenium Framework for Automated Web Testing
What is the Framework? Tool of Choice
InfoStretch Selenium Framework for Automated Web Testing
InfoStretch has developed a framework for Web application testing and test automation using Selenium test tools that focuses on achieving a rapid return on investment – often in less than three months. The InfoStretch framework using Selenium has a robust set of pre-built features that include:
Parallel compatibility testing for many browsers from the cloud, with zero infrastructure costs..
Integration scenario testing across UI’s and Web services.
Highly maintainable and repeatable tests that utilize reusable test assets, proper modularity and semantic structure.
Data-driven Selenium tests with external Excel, XML and CSV-based data.
Drill-down, Junit-style test reports that show key automation metrics across multiple test executions with screen shots of failed tests..
Best practices for coding conventions and process guidelines, and coaching on how to make apps "testable."
Integration into many continuous integration/build automation systems such as Hudson.
Few more references:
InfoStretch Test Automation Framework
Choosing a test automation framework
Test Automation Framework
Designing An Automated Test Framework