3.14.5. Using variables as data for Test Cases
Prev | 3.14. Working with test data | Next

### 3.14.5. Using variables as data for Test Cases

- You can store values from the AUT during a test to use later in the test.

- Some actions (e.g. store value) let you save a value as a variable. You specify the name of the variable, e.g. USERNAME. Note that only standard ASCII alphanumerics and the underscore are allowed in variable names, that is, the characters 'a'...'z', 'A'...'Z', '0'...'9', '_'.

- When you want to use the variable, you can enter it as a parameter by preceding it with a dollar sign: $USERNAME. The parser will interpret the longest sequence of allowed characters after the $ sign to constitute the variable name, e. g. $VARÜABLE is interpreted as the value of the variable named VAR followed by the literal text 'ÜABLE'.

For more information on using variables, see the following sections:

- Working with variables in tests (Section 3.14.5.1, “Reading and using values (variables) from the AUT”).

- Working with system variables (Section 3.14.5.2, “Using environment variables in tests”).

- Working with the pre-defined variables (Section 3.14.5.3, “Using the pre-defined test execution variables”).

#### 3.14.5.1. Reading and using values (variables) from the AUT

You can store values read from the AUT to use as data in other Test Cases.

1. Use one of the store value actions on the various components to reads a value from a component in the AUT.

   | You can also use the store value action on the application component to store a value you enter.

2. In the parameter field, enter a name for this variable (e.g. USERNAME).

   | Variable names may only contain letters, numbers and underscores

3. When you want to use this value as data for a parameter, enter the variable name preceded by a dollar sign ($) as the parameter value (e.g. $USERNAME).

   Bear in mind that the variable has to be stored before it can be used as a parameter value.

Read the following sections for more information on:

- Using system variables in tests (Section 3.14.5.2, “Using environment variables in tests”).

- Using the pre-defined variables in tests (Section 3.14.5.3, “Using the pre-defined test execution variables”)

#### 3.14.5.2. Using environment variables in tests

You can add variables to your operating system, which can be used in your tests.

You will need to set environment variables which have the form:

TEST_UDV_<variablename>

To use the variable in your tests, enter the variable name (everything after the underscore) preceded by a dollar sign. Do not enter the ”TEST_UDV_” part.

| After entering or changing an environment variable, you will need to restart the ITE. Environment variables for the ITE (i.e. for the test) are only read from the machine on which the ITE is running, not from the machine where the AUT Agent is running.

Your system administrator will be able to help you with operating-system specific ways of setting environment variables.

Useful variables These variables can be used as environment variables on your machine or as JVM properties in your AUT configuration.

TEST_AUT_KEEP_ALIVE_DELAY

  This can be useful if you are using the action to prepare for termination. You can use this variable to configure (in millseconds) how long the AUT should be ”kept alive” after the termination command (e.g. pressing ”Exit” in order for the correct communication between the ITE and the AUT to occur). The value is set to 2000ms per default.

TEST_AUT_POST_DEREGISTRATION_DELAY

  This can be useful if you are using the action synchronize shutdown and re-start. You can use this variable to configure (in milliseconds) how long your AUT requires after closing to perform tasks such as saving resources and settings.

#### 3.14.5.3. Using the pre-defined test execution variables

1. There are pre-defined test execution variables which you can use in your tests.

2. The following variables are automatically initialized when executing a Test Suite:

   TEST_PROJECT_NAME:

     The Project Name.

   TEST_PROJECT_VERSION:

     The Project version.

   TEST_TESTSUITE:

     The Test Suite name.

   TEST_USERNAME:

     The account name you are logged into your computer under.

   TEST_DBUSERNAME:

     The database user.

   TEST_AUTAGENT:

     The hostname for the AUT Agent the test is running on.

   TEST_PORTNUMBER:

     The port number for the AUT Agent the test is running on.

   TEST_AUT:

     The AUT name.

   TEST_AUTCONFIG:

     The AUT configuration name.

   TEST_AUT_ARGUMENTS:

     The arguments passed to the AUT.

   TEST_CLIENTVERSION:

     The version of the ITE you are using.

3. To use the value of one of these variables in your test, enter:

   `${VARIABLE_NAME}`

   as the parameter value.