When you record a business process, VuGen generates a script that contains the actual values used during recording. Suppose you want to perform the script’s actions (query, submit, and so forth) using different values from those recorded. To do this, you replace the recorded values with parameters. This is known as parameterizing the script. The resulting Vusers substitute the parameter with values from a data source that you specify. The data source can be either a file, or internally generated variables.
You can use parameterization only for the arguments within a function. You cannot parameterize text strings that are not function arguments. In addition, not all function arguments can be parameterized.
Input parameters are parameters whose value you define in the design stage before running the script. Output parameters you define during design stage, but they acquire values during test execution. Output parameters are
often used with Web Service calls.
Example: Let’s say you recorded a Vuser script while operating a Web application. VuGen generated the following statement that searches a library’s database for the title "UNIX":
web_submit_form("db2net.exe",
ITEMDATA,
"name=library.TITLE",
"value=UNIX",
ENDITEM,
"name=library.AUTHOR",
"value=",
ENDITEM,
"name=library.SUBJECT",
"value=",
ENDITEM,
LAST);
When you replay the script using multiple Vusers and iterations, you do not want to repeatedly use the same value, UNIX. Instead, you replace the constant value with a parameter:
web_submit_form("db2net.exe",
ITEMDATA,
"name=library.TITLE",
"value={Book_Title}",
ENDITEM,
"name=library.AUTHOR",
"value=",
ENDITEM,
"name=library.SUBJECT",
"value=",
ENDITEM,
LAST);
Parameter Types
Every parameter is defined by the type of data it contains. This section contains information on the different parameter types.
- File Parameter Types: Data files hold data that a Vuser accesses during script execution. Data files can be local or global. You can specify an existing ASCII file, use VuGen to create a new one, or import a database file. Data files are useful if you have many known values for your parameter. The data in a data file is stored in the form of a table. One file can contain values for many parameters. Each column holds the data for one parameter. Column breaks are marked by a delimiter, for example, a comma. In the following example, the data file contains ID numbers and first names:
id,first_name
120,John
121,Bill
122,Tom
- Table Parameter Types: The Table parameter type is meant for applications that you want to test by filling in table cell values. Whereas the file type uses one cell value for each parameter occurrence, the table type uses several rows and columns as parameter values, similar to an array of values. Using the table type, you can fill in an entire table with a single command. This is common in SAPGUI Vusers where the sapgui_table_fill_data function fills the table cells.
- XML Parameter Types: Used as a placeholder for multiple valued data contained in an XML structure. You can use an XML type parameter to replace the entire structure with a single parameter. For example, an XML parameter called Address can replace a contact name, an address, city, and postal code. Using XML parameters for this type of data allows for cleaner input of the data, and enables cleaner parameterization of Vuser scripts. We recommend that you
use XML parameters with Web Service scripts or for SOA services.
- Internal Data Parameter Types: Internal data is generated automatically while a Vuser runs, such as Date/ Time, Group Name, Iteration Number, Load Generator Name, Random Number, Unique Number, and Vuser ID.
- Date/Time: The current date/time. You can specify the format and the offset in the Parameter Properties dialog box.
- Group Name: The name of the Vuser Group. If there is no Vuser Group (for example, when running a script from VuGen) the value is always none.
- Iteration Number: The current iteration number.
- Load Generator Name: The name of the Vuser script’s load generator (the computer on which the Vuser is running).
- Random Number: A random number within a range of values that you specify.
- Unique Number: Assigns a range of numbers to be used for each Vuser. You specify the start value and the block size (the amount of unique numbers to set aside for each Vuser). For example, if you specify a start
value of 1 and a block size of 100 the first Vuser can use the numbers 1 to 100, the second Vuser can use the numbers 201-300, etc.
- Vuser ID: The ID number assigned to the Vuser by the Controller during a scenario run. When you run a script from VuGen, the Vuser ID is always -1.
User-Defined Function Parameters
Data that is generated using a function from an external 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 *<functionName>(char *, char *)
The arguments sent to this function are both NULL. When you create the library, we recommend that you use the default dynamic library path. That way, you do not have to enter a full path name for the library, but rather, just the library name. VuGen’s bin directory is the default dynamic library path. You can add your library to this directory.