Let’s work with variables and validations inside a Performance sequence. These tools let you parameterize values, generate dynamic inputs, and add checks that verify system behaviour during a load test.
Replace a hard-coded value with a variable
To begin, identify the part of your script where you want to replace a hard-coded value with a variable. In this example, the goal is to parameterize a file name by replacing the static number with a value generated at runtime.
Click the line where the variable will be used. Before editing it, create a random value generator by inserting a randomizer. Choose the option to generate a random number and set the range by double-clicking the starting value. The generated number will be stored in a variable.
With the variable created, return to the line you want to modify. The URL field displays the resource that Performance is fetching. Delete the hard-coded number and right-click. The variable you created appears in the context menu. Select it to insert the variable into the URL.
Press Enter to confirm the change. The line previously containing the fixed value now uses the variable, meaning that each execution of this sequence will fetch a resource determined by the variable. This is a practical example of how to make script steps dynamic rather than static.
Add active validations
Performance also allows you to add active validations. For any step in the sequence, you can open the details and specify what type of content it represents. You can then right-click to add a validation to the response header. This inserts a formatted assertion directly into the script. The assertion becomes part of the execution flow and verifies that the resource matches the expected type or value.
Benefits of using variables and validations
These techniques help you make sequences:
-
More realistic
-
More flexible
-
More precise
Variables introduce variation into the requests, while validations help ensure that the system responds correctly during performance testing.