In the context of successful implementation of QTP for a software testing project we often come across the concept of frameworks. Framework is nothing but the approach that we consistently follow during the automation process – a set of guidelines.
Personally, I don’t like to give names and say that one works better than the other. The selection of a certain framework is not the beginning of a project. It is the reverse that is true. In the process of devising a testing strategy you build the rules that are applicable to the tester’s current situation and that right there is your framework.
Having said that, the following are some of the important points we need to consider:
- Reusability
- Script’s easy maintenance
- Readability of scripts
- Good workable folder structure for all the test assets
- No hard coding values
- No cascade of failures. (i.e. if one test fails, it should not cause the failure or stopping of the others)
Any testing strategy that tries to incorporate some or all of these above points is your Test Automation Framework.
There are various names and types of frameworks. The following is the list of frameworks according to me:
Types of Automation Frameworks:
- Linear – Simplest form of creating a test. Just write a one single program without modularity in sequential steps
- Keyword driven – Create different keywords for different set of operations and in the main script we can just refer to these keywords.
- Data driven – To run same set of operations on multiple sets of data that are kept in separate files, mostly excel sheets.
- Hybrid – A combination framework that can be partly data driven and partly keyword driven
- BPT – This just means that programs are broken down into business components and are used with one or the other of the above types of frameworks
Linear Framework
As discussed this approach involves simply writing the code as we record and keep going.For example, if the operation that you have to verify is the creation of a new account in gmail the following will be the steps:
a) Open gmail.com
b) Click on ‘Create Account’
c) Enter the details
d) Verify the details
e) Create the account
1
2
3
4
5
6
7
8
9
10
11
12
| 'Open GMail 'Page Sync Browser( "Gmail" ).Page( "Gmail" ).Sync ‘Click on create account Browser( "Gmail" ).Page( "Gmail" ).WebLink(“Create Account”).Click ‘Enter the details Browser( "Gmail" ).Page( "Google Accounts" ).WebEdit(“First Name”). Set “Swati” Browser( "Gmail" ).Page( "Google Accounts" ).WebEdit(“Last Name”). Set “test” ‘Fill in several other details ‘Submit Browser( "Gmail" ).Page( "Google Accounts" ).WebButton(“ Next Step ”).click |
Advantages:
- Simplicity. For beginner programmer this method is apt
- Time – It does not take a lot of time to create the test
- Very little planning is required
- No reusability at all
- If there is another script that verifies a certain aspect of the ‘Google Accounts’ Page then you will have to rewrite the code to launch gmail.com page too. So lots of repetition.
- All the data is directly embedded into code. The hard coding does not let the code be used for any other set of data.
- Error prone and maintenance is difficult
The components or test assets in this kind of frameworks are:
- Test script
- Object repository (This can be avoided by using descriptive programming if needed)
Keyword driven Framework
How can we make the above linear framework test better? How can we overcome the cons?Obviously, we need reusability, modularity and readability. Trying to incorporate these features and arriving at an optimum solution is nothing but an attempt at creating a new, more improved framework.
- Launching of gmail and arriving at the ‘Google Accounts’ page. This is a given, since validating this page means to first get here. ‘GoTo Google Account” – can be made into a separate function that can be called over and over again.
- Enter the details and validating them – You can further break this up into positive and negative blocks to include more level of modularity
- Account creation – The final level of validation and accomplishing the task at hand
Functions:
So far in our series we have not dealt with functions. Functions are nothing but a piece of code that does a certain operations. It accepts input parameters from the program that calls it and returns value to it.
As a general practice all the reusable pieces of code are grouped into a file that contains all the reusable functions. This file is associated as a resource to your QTP test. Typically a function library can be a file of the type: .vbs, .txt or .qfl
Back to our example – This is how the function library file can be:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| Function gotoGoogleAccount() 'Open Gmail 'Page Sync Browser( "Gmail" ).Page( "Gmail" ).Sync ‘Click on create account Browser( "Gmail" ).Page( "Gmail" ).WebLink(“Create Account”).Click ‘Enter the details End Function Function EnterDetails() Browser( "Gmail" ).Page( "Google Accounts" ).WebEdit(“First Name”). Set “Swati” Browser( "Gmail" ).Page( "Google Accounts" ).WebEdit(“Last Name”). Set “test” ‘Fill in several other details End Function Function SubmitToCreate() ‘Submit Browser( "Gmail" ).Page( "Google Accounts" ).WebButton(“ Next Step ”).click End Function |
1
2
3
4
5
6
| 'Open GMail gotoGoogleAccount() ‘Enter the details EnterDetails() ‘Submit SubmitToCreate() |
You can also see that in your script the function names are functioning as if they are VBScript’s keywords and hence the name for this framework.
The components or test assets in this kind of frameworks are:
- Test scripts
- Shared OR
- Shared function library
We will discuss Data driven and Hybrid frameworks in detail in the coming tutorial.
No comments:
Post a Comment