Custom code enables you to perform such tasks as managing
loops, retrieving virtual user information, running external programs
from tests, and customizing data correlation.
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 variable values
You can use the getValue() and setValue() methods to store
and retrieve values in variables. Depending on the storage location
that you specify, variables can be shared among tests, or stored locally
in the current 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.
Adding custom counters to reports
You can add custom counters
to performance reports by using custom code. After running tests,
the results from the custom counters are automatically aggregated
in the same way that the default performance testing counters are
(for example, byte and page counters). The aggregate for the custom
counters is combined from all agent computers.
Using transactions and statistics
You can use custom code to
start transactions, gather additional statistics during a transaction,
and stop a transaction.