Thursday, 16 February 2012

Naming conventions in QTP

Naming convention is a good practice to trace Use cases , Test Cases, Test Scripts, Action(s), Object repositories etc. Since each of the above mentioned items have relation with others, it’ll be good if a unique naming convention is used across the Automation Test suite.
Test Case: 
Test cases should be named in such a way that the corresponding Use cases can be traced for which the test case is written. Other users should be able to trace the Test Cases based on the Use Case or Scenario or Test condition. Consistency should be maintained when naming the Test Cases.
For example, we can name the Test case as TC_001. So, the corresponding Use case naming convention would be UC_001.

Script & Action: 
Similar to the Test cases naming, script should also be named with clarity in such a way that the script is traceable. Typically each Test Script is prepared corresponding to each Test Case. Every Test can contain one or more conditions. Each condition can be represented by Action in the script.
For example, we can name the script name as “QTS_001” for the Test case number “TC_001”.
Action Naming:
 Each test can have one or more conditions. It can be represented by one or more Actions. We can name the Actions in two ways.
Naming based on the functionality of the Action and Hierarchy of the action in the script.
We can name the action based on the function in such a way that it’s easily traceable. For example, we can name the logout functionality action as “Logout_User”. Like this we can have different names for each actions in such a way that it’s reflecting the functionality as well as Traceable.

Hierarchy of the Action in Script: One test case may have one or more conditions. It can be represented by one or more actions. 

Based on the above examples, we can have the following naming conventions.
First Test Case: TC_001
First Use Case: UC_001
Test Script: QTS_001
First action in script: QTA_01_01
Tenth action in script: QTA_01_10
Variables and Constants: QTP uses VB script. So, we can use the same convention used in VBScript for variables and constants.

 We have Global and Local data sheets in QTP. Global data sheet can be used by all actions available as part of QTP automation framework. In general we used to mention the Global data sheets as “dt_globalsheet”. We can rename the global data sheet as “Global” to maintain the consistency.

Local data sheets can be used by the action to which it belongs to. This can be named after the action to which it belongs. So, we can name the data sheet by using the name of the action. For example, we can use the naming for “Login” action sheet as “Login_DataSheet”.

Parameter Naming:
We have different types of parameter in QTP.
Test Input Parameter: We can name the input parameters something like “IN_uName”.
Test Output parameter: Output parameter can be named something like “ACTOUT_actNo”
Action Input Parameters: These are local to the action.These can be named as “ACTION_varname”.
Action Output Parameters: These can be named as “ACTOUT_varname”.

Environment variables: 
These variables can be user defined or built in.  Built in variables are internal.So, we can’t name the Built In Environment variables.
User defined variable are Internal and External. We can name the internal user define environment variables as “ENV_INT_variablename” and the external user defined environment variables can be named as “ENV_EXT_variablename”.
Functions: Functions can be named as “Func_name”. For example we can name the Login function as “Func_Login".


Post a Comment

Back To Top