Importance of Test Automation Frameworks
Sreepad Bhagwat
Director, Quality Engineering and Enterprise Automation(RPA, Test Automation, DevOps and Dashboards)
Lot of articles are written about Test Automation Frameworks. When writing this article I was wondering if I am trying to share yesterday’s concept tomorrow. With the advent of SDET roles and ATDD rolling out in lot of organizations I thought it was important to rediscover, redefine and re emphasize the importance of test automation frameworks. What is old can be new again.
Speaking to some of the developers, I often hear statements like we are developers and we don’t need any frameworks and we have capability to author quality scripts. My response is simple. Framework is not about a skill but it is about design and process. Software design was evolved with an objective to make life easier and simplify coding. This is one of the reasons we see lot of frameworks in java world to simplify coding (Spring being one of the examples).
I am working as automation developer for several years. I was involved in assessment of automation projects for different organizations. The common and biggest challenge I have faced is to get automation teams stop making things harder than they have to be.
Below are some of the common challenges
- Automation assets grow quickly over a period of time. It increases the complexity of maintenance
- Automation development is not given same attention as other projects as automation is not customer facing
- Process like code review etc is often ignored owing time constraints. This resulted in false positives.
I have basically seen two approaches to test automation.
Approach 1 : Traditional approach of writing scripts where you write your scripts at one place and create a monolith. Software design techniques are not followed in this approach. Tool specific methods, tests, test data etc is kept together as a single code base.
Approach 2 : Decompose larger code base into small manageable methods. All the actions are authored as methods. Some of the software design techniques are followed in this approach. This approach is often called automation framework.
Automation Frameworks are set of objects that encapsulate different methods and provide programming interface to the end user. Frameworks also include methods to access object repository and manage data structures to access test data. Automation frameworks can also be called as wrappers created on top of automation tools.
Why do we need Automation Frameworks
Anyone who understands software design will inherently understand why it makes sense to design a framework. Here are some of the benefits of automation frameworks.
- It is fundamental that teams need to invest time to learn automation tools. Frameworks provide foundation (methods or api’s) for teams and these methods can be accessed directly to interact with elements on the page or screen.
- Most of the automation developers are not trained in software design or programming. This results in independent style of coding for similar actions. Every individual has a specific style of coding. It is quite a challenge to review and maintain the best coding practices for all the scripts. Frameworks provide api’s to actions and also provide control to the object’s behaviour. Keeps your code DRY (Don’t Repeat Yourself).
- For the same error, each developer writes his/her own error handling statements. Independent coding behaviour results in different error handling statements. Frameworks help to control object at a fine-grained level including error handling.
- Well designed framework helps us to develop different aspects of code in isolation. Tool specific code is isolated from test specific code. Tool specific objects are built to make end user’s life easier. Test specific code uses tool specific objects for any interaction with elements on page. This results in less coding for end users.
- Frameworks are combination of the objects and project components. Different components will help you enforce separation of responsibility for easier maintenance.
- Separation of code makes debugging easier
- You can define well performing, well-defined, well-understood and context methods using framework objects.
- Framework components are developed in advance, this helps to develop scripts in parallel.
- Frameworks bring discipline to coding. Enforces to use reusable methods / api’s where end user has no choice but to adhere to the rules.
To avoid maintenance pitfalls is not to create one. One of the better automation designs is the one with the combination of API and page object model. I will discuss this model in detail in my next blog. Frameworks are way to go. It is a good for everyone. It makes everyone’s life easier
I have authored two open source projects this year based on the above discussed model.
- screen-object ruby gem for mobile application automation.
- rest-test (yet to be released) for testing Rest API Services
Quality Engineering | Performance Engineering | AI Testing
8 年Crisp & Clear Article
Managing Director - India | Global Technology executive
8 年Very good article. Thank you for sharing. Please continue to contribute to the open source community.