Saturday, November 22, 2014

How to create a Framework?

How to create a framework?

There is no hard and fast rule for this... Practically, every project has its own expectation. You just need to start your work in organized way and at the end of the day; your framework will be ready automatically.
You can't design a complete framework and then start automation! You start automation and framework will start building simultaneously.

The first step of any test automation framework is to do a quick POC with few high priority test cases. By doing POC, you will identify
  1. the object identification issues, 
  2. challenges, 
  3. complexities, 
  4. required test-data and 
  5. limitation you have. 
Once you are ready with this information, you can proceed with next steps. On the basis of above information, you can decide what type of framework is most suitable to you.


But before starting, you must take some time to decide your strategies about..

  1. Object Identification
  2. Test-Data
  3. Function Library
  4. Error Handling
  5. Controller/Driver script
  6. Documents and Manuals
  7. Test Reults

Object Identification:
One of the most important aspect of QTP automation is - How to identify objects i.e. using Object Repository(OR) or Descriptive programming(DP) or both. Don't stick on one particular. Depending on the application types, mixed approach is most fruitful.

Although both OR and DP have their own pros n cons, but remember, you get full benefit of QTP only when you use OR like debugging, chechpoints etc. So make sure how to identify objects.

Few claims that DP should be used each time but I disagree. DP is nice thing to use but should be used only when required like if your application is having dynamic objects etc. Doing whole automation using DP without any solid reason is not sensible (personal opinion!).

Test-Data:
How to manage you data? DataTable or Excel or may be flat/csv files.

Function Library:
Function library could be QTP specific (.qfl) or external (i.e. .vbs). Be clear about what type of function libraries you are going to use and why.

Error Handling:
Whets your plan to handle errors? Be clear about it. Are you going to use QTP's Recovery Scenarios or you will be writing your own vbs functions?

Controller script:
Design a controller script, which will control all your automation. It should be neat. This helps to understand what actually you are going to call.

Documents and Manuals:
Keep all the documentation, user guide/manuals, keywords descriptions here.
Test Results:
Result is probably most important part of the framework. Because result is the face of your framework! This is what you show to world. If your result is fantastic, nobody bothers what have you written in your functions!! :) But if results are not flashy.. then.. you know!!

So never underestimate the importance of the results. It must be very well presented.


Create different folder for the these seven things and keep data in folders accordingly.

Apart from this, from first day of your automation, keep only one thing in your mind.. follow general good practices!

Here are few points need to be take care in designing successful framework.

  1. Try to document each and every thing, as much as you can! like comments in script, modification etc.
  2. Don't stick with any particular object identification, use mix of OR and DP.
  3. While using OR, don't use record and playback, just add object in the object repository and code the script manually.
  4. Follow proper Naming-Conventions for all your variables, functions, files.
  5. Define all the variables in you scripts, use Option Explicit.
  6. Try to keep you functions small to enhance reusability and portability.
  7. Never hard code any data in the scripts, use parametrization.
  8. Take regular back-up of your work.

No comments:

Post a Comment