Custom code enables you to perform such tasks as managing loops,
retrieving virtual user information, running external programs from tests,
and customizing data correlation.
You can extend test execution in the following ways:
Store objects in data areas. Rational® Performance Tester provides
data areas that contain objects for engine, virtual user, test, and HTTP information.
For a code example of storing an object, see Storing and retrieving a string.
Manage the behavior of loops. For a code example, see Controlling loops.
Run a batch file or program that sets up the environment needed for a
test and resets the environment afterward. For a code example, see Running an external program from a test.
Controlling loops
This example demonstrates extending
test execution by using custom code to control loops. It provides sample code
that shows how you can manipulate the behavior of loops within a test to better
analyze and verify test results.
Retrieving the IP address of a virtual user
This example shows how to retrieve
the local IP address of a virtual user. Retrieving IP addresses is particularly
useful when virtual users are using IP aliases.
Printing input arguments to a file
The PrintArgs class prints its input arguments to the file C:\arguments.out.
This class could be used, for example, to print a response returned by the
server.
Counting the number of times that code is executed
The CountAllIterations class counts the number of times code is
executed by all virtual users. The CountUserIterations class counts the number
of times code is executed by an individual virtual user.
Storing and retrieving a string
The DataShare class enables a virtual user to store a string value
in one test and then retrieve it in a different test.
Extracting a string or token from its input argument
The ParseResponse class extracts a string from its input argument.
The ExtractToken class extracts a particular token (string) from its input
argument. Both classes can be useful for handling certain types of dynamic
data correlation.
Using transactions and statistics
You
can use custom code to start transactions, gather additional statistics during
a transaction, and stop a transaction.