Parameterization
Parameterization technique is used to pass different data in the script at different instances during execution. A simple example is of a login request, by parameterizing the credentials in the request, we can pass different set of credentials for each vuser.
This technique drives the test with different set of data.
Various steps of parameterization are
1) Locating the data to parameterize
2) Naming the parameter
3) Selecting the type of parameter to be created
4) Defining properties for the parameter
5) Replacing the data with a parameter
6) Replacing other occurrences of the same data with the parameter
To parameterize a data in the request
- highlight the data to parameterize
- Right click and select “Replace with parameter”
- Give a name to the parameter, click ok.
- We can see the value replaced with {parUserName}, the parenthesis depends on the parameterization settings and so it may change accordingly. By default they are set to “{}”.
- If there are multiple instances of the parameterized data in the script, simply highlight the data, right click, go to “Use Existing Parameter” and select the required parameter from the list.
- The other way to replace multiple instances of parameterized data, right click on the parameter(in the above case parUserName), replace more occurrences.
- For each parameter created of type “file”, “table”, “xml” there is a parameter file (.dat) created in the script folder.
- The different parameter types available are
- BPT
- Custom
- Date/Time
- File
- Group Name
- Iteration Number
- Load Generator Name
- Random Number
- Table
- Unique Number
- User Defined Function
- VUser ID
- XML
All the parameters created for a script can be viewed under Vuser -> Parameter List or by using shortcut Ctrl+L.
The original value of the parameter can be restored by right clicking on the parameter instance and then selecting restore original value.
File Type Paramteter
- This is a very commonly used parameter type. It has an associated parameter file in the script directory.
- For instance, when we create a file type parameter with a name “param” then a new file param.dat will be created in the script directory or we can specify the path to an existing paramter file explicitly in the properties.
- This file is contains rows and columns of data. We can add, delete rows and columns in the data file through options “Add_Row” , “Add_Column”, “Delete_Row” and “Delete _Column” available in the properties view.
- Select Column: if the parameter file has multiple columns, we can specify the column to be selected. In this way we can have multiple parameters associated with the same file but having different columns selected. The column can be selected by column name or number.
- A parameter of type file can refer to rows of only one column at a time.
- File Format: In this we select the column delimiter and the first data line. Depending on the type of file select for the parameter i.e. whether it is a comma, tab or space separated file, the column delimiter is selected. First data line specifies the line to be set as the first row for the parameter. E.g. if the file contains 20 lines of data and the first data line for the parameter is 3 then the 3rd line would be the first row for the parameter and the total rows would be 18(3rd to 20th).
- Select next row: This option defines the way the data should be selected for the parameter during execution
- Sequential: With this option, the parameter will hold the same value during the same iteration.
- Unique: With this option, the parameter will hold a unique value for each vuser. When this option is selected the total rows of data should at least be as many as the total vusers.
- Random: With this a option, a value randomly selected.
- Same Line as……: With this option the data row for the parameter can be aligned with that of another parameter. E.g. Suppose we have two parameters one for user name(parUN) and other for password(parPass) then the Select next row for password will be set to same line as parUN.
- Update value on: This option specifies the way the data should be updated for the parameter.
- Each iteration: For every iteration the value will be updated
- Each occurrence: Each the parameter occurs in the script, the value for this parameter will be updated.
- Once: With this the value is not updated after first data selection for the parameter.
- When out of values: This setting decides what needs to be done when the parameter is out of values. This option is enabled only when Select next row = Unique and Update value on = Each iteration/Each occurrence. The options available are Abort Vuser, Continue in a cyclic manner and Continue with last value.
- Allocate Vuser values in the Controller: This setting is enabled only when Select Next Row = Unique. This setting specifies the data block size allocation i.e. the number of data rows of a parameter to be assigned to a particular Vuser during execution. There are two options either let the block be allocation automatically or specify a block size.