Sunday, May 22, 2011

Automation Framework


An automation framework is a set of guidelines like:
  • Coding Standards , 
  • Test data handling , 
  • Object repository treatment etc. 
Which when followed during automation scripting produce beneficial outcomes like:
  • Increase code re-usage , 
  • Higher portability , 
  • Reduced script maintenance cost etc. 
These are just guidelines and not rules, they are not mandatory and we can still script without following these guidelines but we will miss out on the advantages of having a Framework.


Available Automation Frameworks:
  1. Linear Scripting.
  2. The Test Library Architecture Framework.
  3. The Data-Driven Testing Framework.
  4. The Keyword-Driven or Table-Driven Testing Framework.
  5. The Hybrid Test Automation Framework


Hybrid Test QTP Framework


  1. This framework is the combination of one or more frameworks.
  2. Pulling from their strengths and trying to mitigate their weaknesses. 
  3. This hybrid test automation framework is what most frameworks evolve into over time and multiple projects. 
  4. Maximum industry uses Keyword Framework in combination of Function decomposition method.

Keyword Driven QTP Framework


It is also known as "Table Driven Testing Framework" or “Action Word Testing".

This Framework,
1.      Requires the development of data tables and keywords, independent of the test automation tool used to execute them.
2.      Tests can be designed with or without the Application.
3.      In a keyword-driven test, the functionality of the application-under-test is documented in a table as well as in step-by-step instructions for each test.


Components in this framework,
  1. Control File (Scenario Sheet).
  2. Test Case File.
  3. Startup Script (Environment Sheet)
  4. Driver Script.
  5. Utility Script. (VB Script Functions)

Ø       Control File (Scenario Sheet)
a)      It consist details of all the Test scenarios to be automated.
b)      User will be able to select a specific scenario to execute.
c)      Control File is in the form of an excel worksheet.
d)      It contains columns for Scenario ID, Execute (Y/N), Object Repository Path,   test Case File path.

Ø       Test Case File 
a)     It Contain the detailed steps to be carried out for the execution of a test case.
b)      It is also in the form of an excel sheet and contains columns for Keyword, Object Name, Parameter.

Ø        Startup Script (Environment Sheet)
a)     The startup script is utilized for the initialization and reads the control files.
b)     It’s a place to declare global variables & paths.
c)     It then calls the driver script to execute all the scenarios marked for execution in the control file

Ø       Driver Script
a)     It Reads the Test Case files.
b)     Checks the keywords and calls the appropriate utility script functions based on specific keyword.
c)     Error Handling is taken care of in the driver script.

 
Ø       Utility Scripts (VB Script Functions)
a)     Perform generic tasks that can be used across applications.


Advantages:
     1.      Provides high code re-usability.
2.       Test Tool Independent.
3.      Independent of Application under Test, same script works for AUT (with some limitations).
4.      Tests can be designed with or without AUT.

Disadvantages:
  1. Initial investment being pretty high the benefits of this can only be realized if the application is considerably big and the test scripts are to be maintained for quite a few years. 
  2. High Automation expertise is required to create the Keyword Driven Framework. 

Data-Driven QTP Framework.


In this Framework,
  1.  Test case logic resides in Test Scripts.
  2.  Test Data is separated and kept outside the Test Scripts.
  3.  Test Data is read from the external files.
  4.  The external files may be Excel Files, Text Files, CSV Files, ODBC Sources, DAO Objects etc)
  5.  The external files are loaded into the variables inside the Test Script. 
  6.  Variables are used both for Input values and for Verification values.
  7.  Test Scripts themselves are prepared either using Linear Scripting or Test Library Framework.
Advantages:
  1.  Changes to the Test Scripts do not affect the Test Data.
  2.  Test Cases can be executed with multiple Sets of Data.
  3. A Variety of Test Scenarios can be executed by just varying the Test Data in the External Data File.
Disadvantages :
  1.  More time is needed to plan and prepare both Test Scripts and Test Data.

Example :

Developing  Login script using this method will involve two steps.

 Step 1) Create a Test - Data file which could be Excel , CSV , or any other database source.
  
Username                 Password
Ankur                        Password1
Ankit                         Password2
Ashu                         Password3 

  
Step 2) Develop Test Script and make references to  test data source.
  
Dialog("Login").WinEdit("Username:").Set DataTable("Username", dtGlobalSheet)

Dialog("Login").WinEdit("Password:").Set DataTable("Password", dtGlobalSheet)

Dialog("Login").WinButton("OK").Click


Saturday, May 21, 2011

Test Library Architecture QTP Framework.


It is also know as "Structured Scripting" or "Functional Decomposition".



In this Framework,


  1.  Test scripts are initially recorded by “Record & Playback” method. 
  2.  Common tasks inside the scripts are identified and grouped into Functions.
  3.  These Functions are called by main test script called Driver in different ways to create test cases.


Advantages:

  1. Higher level of code reuse is achieved in Structured Scripting as compared to “Record & Playback”.
  2. The automation scripts are less costly to develop due to higher code re-use.
  3. Easier Script Maintenance(Common functionality need to modify at one place only). 

Disadvantages:

  1. Technical expertise is necessary to write Scripts using Test Library Framework. 
  2. More time is needed to plan and prepare test scripts. 
  3. Test Data is hard coded within the scripts(data tables are not used). 

Example:


Function for logging in to an application will look like:

Function Login()

Dialog("Login").WinEdit("Userame:").Set "Ankur"

Dialog("Login").WinEdit("Password:").Set "Password1"

Dialog("Login").WinButton("OK").Click

End Function 


Now, we can call this function in the main script as follows

'Driver Script

Call Login()


Linear Scripting QTP Framework


It is the simplest of all Frameworks and also known as "Record & Playback".


In this Framework,
  1.  Tester manually records each step (Navigation and User Inputs).
  2.  Inserts Checkpoints (Validation Steps) in the first round. 
  3.  Plays back the recorded script in the subsequent rounds.

Advantages:
  1. Fastest way to generate script (No programming is required at all).
  2. Automation expertise not required.
  3. Easiest way to learn the features of the Testing Tool.

Disadvantages:
  1. Little reuse of scripts (functions are not used).
  2. Test data is hard coded into the script (Data table is not used).
  3. Maintenance Nightmare (If the requirement/test data is changing very frequently then it’s very difficult to modify).

Example:


Consider logging into an application and checking whether the application has loaded on successful log-on. Here, the tester will simply record the steps and add validation steps.


Dialog("Login").WinEdit("Username:").Set "Ankur"

Dialog("Login").WinEdit("Password:").Set "Password1"

Dialog("Login").WinButton("OK").Click

Search This Blog