Declaring and assigning test variables
You can declare a variable, create a container for it, initialize it to a string or a dataset value, and set its scope. Then, within the test, you can reassign another value to the variable.
About this task
If the data that you want to assign to a variable is only available after a specific test step, instead of initializing the variable, you need to add a variable assignment further down in the test, so that when the assignment occurs, the data that you need to use is available. Otherwise, when you try to initialize the variable (or do the assignment), the value that you want to use will not be available and will not show up as an option to select.
If a variable is initialized at various places such as test, compound test,
schedule, or user group, the product uses the following order to initialize the value of the
variable when running the test. The variable set in the variable table of the compound test
editor takes the highest precedence followed by others:
- Compound test setting in the variable table UI
- Compound test specified in a var file
- User group setting in the variable table UI
- User group specified in a var file
- Schedule specified setting in the variable table UI
- Schedule specified in a var file
- Command line
Note: You must select All tests for this user
from the Visible in drop-down list to take the precedence of variable
initialization.
Procedure
-
Double-click the test to open it from the Test Navigator view.
The test opens.
-
Create a container for the test variables that you create in a test:
-
Declare and define a test variable:
-
Assign a test variable to a test element and set a value: