Defining Global Variables

Global variables can be shared between test cases. These vary from local variables, which are only available to specific test cases.

Global variables can be used as input parameters for function calls and can also be used to store return values. Global variables are configured with an initial value, which makes them useful when you need to have the same value used for multiple function calls. Each time a test run begins, global variables are initialized with the defined initial value. The initial value can be changed if the variable is used to store result values.

When exporting global variables to Silk Performer, the global attribute can be retained as a Silk Performer project attribute, enabling you to also configure the initial values of global variables. To be able to modify the project attribute value in Silk Performer, you must set the UseAttribute value of the External Access property in the Input Data Properties pane to True before exporting the project.

Note: Global variables of type string and byte[] can be initialized from data files (.txt files). This is useful when a lot of content must be passed to a method call. Rather than manually typing the content into the edit control, you can initialize a variable from a specified file. The From File text box is only enabled when the variable type is System.String or System.Byte[].
  1. Select the Objects tab. Right-click an object in the Objects tree menu and select New Global Variable. The Global Variable dialog box displays.
  2. Type a name for the variable in the Variable Name text box.
  3. Select a Variable type. The following types are available:
    • string
    • integer
    • boolean
    • double
    • single
    • byte
    • byte array
    • date/time
  4. Each variable has an initial value and a current value. When tests are run, all global variables are initialized to their initial values. Specify an intial value for the variable in the Initialize Value text box. You can also take the initial value from a file by clicking the from File option button and then specifying the file location by clicking (...).
  5. Click OK.