Using Persistent Variables
If you need to store variables between tests, use persistent variables. PTF stores persistent variables to the database so that subsequent test executions can use them.
Persistent variables are stored in the database keyed by execution option name. Persistent variables can also be keyed by User ID, machine name, or both.
There are two key elements required to use persistent variables:
Set the variable action in the test.
Set persistent variable options.
Setting Variable Option in the Test
To set the variable option in the test, use the Test Property icon.
Create a new test or open an existing test.
Click on the Test Properties icon.
Set the Variable Action field.
None (default). The test will not be using persistent variables. All variables set in the test are only global to the current test execution.
Read. The test can only read persistent variables from existing persistent variables in the PTF test database.
The test can only write persistent variables to the PTF test database.
Read & Write. The test can read and write persistent variables from and to the PTF test database.
Setting Persistent Variable Options
Managing Persistent Variables
Use the Manage Persistent Variables page (PSPTTSTPERVAR) to modify or delete persistent variables.
Image: Manage Persistent Variables page
This example illustrates the fields and controls on the Manage Persistent Variables page. You can find definitions for the fields and controls later on this page.
This page will list all the persistent variables stored in the database. The variable is stored when the test writes the variable to the database.
The variable is always stored with the name of the execution option. The User ID and Machine Name are dependent on the selection you made for the persistent variable on the Advanced Options page of the Execution Options.
You can delete persistent variables or modify the variable value.
Example of a Test that uses Persistent Variables
This example shows a test where the variable action was set to Read & Write in the Test Properties. The variable &userid exists in the persistent variable table.
Image: Example of using persistent variables in a test
This example illustrates reading a persistent variable (&userid) and writing a persistent variable (&role).