Sunday, September 13, 2009

Introduction to Vuser Parameters

Why do you think we need the concept of parameterization? The answer for this question is simple humans get bored by doing monotonous job and also our application is just not just accessed by one person or is not just for one purpose. Consider the following example. You have recorded a script which will log into a bank application to check the balance of a person/account. If u replay the script, it checks the balance of the same person /account. But our goal of replaying the script is to check how application behaves when different user persons/ accounts check their balances. So to adopt our script to test for different accounts we need to implement the concept of parameterization. That means if we parameterize Account field then script uses different accounts for each of its iterations. For 1st iteration it may use to check account balance of Sam, for second iteration it may check for Mahesh and so on….
Lets go over in detail on the parameters: Inserting parameters in the script:
  • Select the text you want to parametrize, right click and select replace with parameter
  • Choose the parameter name (Please follow a standard naming convention) and parameter file type (which we will discuss in detail later). For now choose file.
  • You can successfully parametrized the value in the script
  • Open parameters list, click edit with notepad, enter multiple different values
  • Now run the script, and you can observe that script uses different values for each iteration
Note: You need to set no of iterations more that 1 in the run time settings for the script to run multiple times.
Limitation of parameters:
You cannot parameterize text strings that are not function arguments.
You cannot parameterize all function arguments.
Parameter Types:
The following are the parameter types we have in loadrunner:
  • File or Table parameter types
  • User Defined Parameter types
  • Internal type Parameter types

File or Table Parameter types:

This is the very common method for using parameters in Vugen. Vugen fetches data from external file or data table. We can edit/open this file using notepad. You can also use data wizard to fetch data from database. We can also create new file for storing the data. Vugen access this file during the script execution. One data file can contain multiple columns (each column equivalent to one parameter), and under each columns you have different values. Comma, Tab, Space suffice the job of column delimiters. In the below example a new data file created contains number, firstname, lastname

Number FirstName LastName

1 mm kk

2 00 pp

3 dd ss

User Defined Parameter types:

An external DLL is loaded and data is generated using a function from this DLL. A user-defined function replaces the parameter with a value returned from a function located in an external DLL.. Before you assign a user-defined function as a parameter, you create the external library (DLL) with the function. The function should have the following format: __declspec(dllexport) char *(char *, char *)

Internal type Parameter types:

Data is generated automatically and used for the parameter. For eg if u define data/time then today’s data is used for the parameter (today’s date is replaced for the parameter in the script when the Vuser runs). The other different internal type parameters are : Group name, Iteration number, Load generator Name, random number, Unique Number and Vuser Id. If you choose random as parameter type then for each iteration a random value is substituted in the script during execution. You can choose the max and min value range.

Using Existing Parameters

Paramater is automatically added to the parameter list whenever you create a new parameter. You can use this existing parameter to replace any value in the script or to replace multiple occurrences of that value. Restoring Original StringsYou can also restore original value after undoing the parameterizationTo restore a parameter to its original value:In Script view, right-click on the parameter and select Restore original value. Paramater List:Here You can create new paramaters, edit paramaters, delete parameters, edit parameter values, choose parameter types, set/edit parameter properties, choose data assignment method, data update modes,

No comments:

Post a Comment