Execution variables

To use specific values in your test scripts during a test run, define execution variables in test scripts or keywords. You can also pass execution variables from a test suite or a test case to associated test scripts or keywords. If you are an administrator or a test lead, you can set execution variables at the project level.

You can use execution variables with all manual scripts, command-line scripts, and JUnit Selenium scripts. If you use an adapter that supports execution variables, you can use them with automated test scripts. To determine whether an adapter supports execution variables, consult the adapter-specific documentation.

Artifact- and project-level execution variables

Execution variables can be defined at project or artifact levels. If you are a project administrator and have permission to save project execution variables, you can define project execution variables. Because project-level execution variables are centrally defined, they can be consistently reused across a team. In addition, project execution variables have sets of values, called enumerated values, that are defined for use in test artifacts. The use of enumerated values safeguards testers from accidentally entering an invalid value at run time.

Test authors can define artifact execution variables in the context of test suites, test cases, and test scripts. Those test artifact execution variables can take any value.

  • To use values that are present throughout a test suite or a test case, define artifact execution variables in the Execution Variables section of that test case or test suite.
  • To use an execution variable in a manual test script or keyword, define the variable in the Execution Variables section of the Manual Test editor. After you define a variable, you can insert references to it in a manual test script or keyword step. During a test run, the current value of the execution variable replaces the reference in the step.
  • To set the value of a particular execution variable, you can insert execution variable steps in a manual test or keyword. You can create and insert an execution variable step from the Execution Variables window. During a test run, you are prompted to assign a value to the execution variable. After you set the value, all references to that execution variable have the value that you provided.
At the artifact level, if values for the same variable are defined in multiple places, the values of the higher-level variable override the values of the lower-level variable. For example, a variable is defined in a test suite and in a test case that is within the test suite. The value of the variable that is defined in the test suite overrides the initial value of the variable that is defined in the test case. In another example, a variable is defined in a test case and in a test script that is within the test case. The value of the variable that is defined in the test case overrides the initial value of the variable that is defined in the test script.
Note: For the override operation to work in execution variables, the defined value of lower-level variable cannot be null or blank.
  • The values of test suite execution variables override the values of test case, test script, and keyword execution variables
  • The values of test case execution variables override the values of test script and keyword execution variables
  • A defined test script variable with a null value overrides a keyword execution variable

An artifact can incorporate both project and artifact execution variables. However, if two or more of those variables have the same name, a conflict occurs that prevents the artifact from being saved. You can change the name of a project-level execution variable to match the name of an artifact-level execution variable. In that case, the value of the artifact-level variable overrides the value of the project-level variable when the test is run.

Execution variables in sequential test-suite runs

If you run sequential test suites, you can pass execution variables from one test script to another. For example, the first step in a test suite runs a test script that creates a user and sets an execution variable that is named userID. Subsequent steps in the test suite run test scripts that reference the value of the userID execution variable, update the user information, and verify that the user information is correct. You can enable this behavior in the Test Case section of a test suite or in the Run Test Suite window.

Execution variables in command-line scripts

When you run a command-line test that includes execution variables, the values of the execution variables are provided as environment variables to the process that runs the command-line test. The names of those environment variables start with qm_ to distinguish them from other environment variables.

For example, if a test suite contains an execution variable that is named myVar, an environment variable that is named qm_myVar is created.
Remember: Ideally, execution variable names include only valid Java identifiers: A-Z, a-z, 0-9, _ and $. If an execution variable contains an identifier that is not in Java, an underscore (_) replaces that identifier in the new environment variable name. For example, if you have an execution variable that is named user.Name, the resulting environment variable is qm_user_Name.
In addition, an environment variable that is named qm_ExecutionVariablesFile is created, and its value is an absolute path name to a text file; for example, qm_ExecutionVariablesFile=C:\Users\tneal.DEV\AppData\Local\Temp\QMAdapter1220694107401772431.vars. That file contains name and value pairs: one for each execution variable that is defined when the command-line script runs. For example:

#Execution Variables
#Wed Mar 02 15:48:54 EST 2011
testcase2Var=set statically in testcase2
testcase1Var=set statically in testcase1
testsuite1Var=set statically in testsuite1

When the command-line test is complete, the text file is read. If the test suite allows execution variables to be passed, the contents are used to pass the values of execution variables to the next test script. You can modify the text file to create execution variables or to change the value of execution variables that are passed to other test scripts.

Built-in execution variables

In certain cases, your test might need to retrieve more information about the test execution environment that it is running in. For example, the test might need such the name of the test suite or the test case that is being run. Built-in execution variables provide environment information. To enable built-in variables, select the Include built-in variables check box in the Execution Variables section of the test script editor.

When that check box is selected, these extra execution variables are created:
RQM_TESTSCRIPT_NAME
RQM_TESTSCRIPT_WEBID
RQM_TESTCASE_NAME
RQM_TESTCASE_WEBID
RQM_TESTCASE_RESULT_WEBID
RQM_TESTCASE_RESULT_NAME
RQM_TESTSUITE_NAME
RQM_TESTSUITE_WEBID
RQM_TESTSUITE_RESULT_WEBID
RQM_TESTSUITE_RESULT_NAME
RQM_TESTPLAN_NAME
RQM_TESTPLAN_WEBID
RQM_TESTPHASE_NAME
RQM_TESTPHASE_WEBID
RQM_TESTCASE_EXECUTIONRECORD_NAME
RQM_TESTCASE_EXECUTIONRECORD_WEBID
RQM_TESTSUITE_EXECUTION_ORDER
RQM_TESTSUITE_TOTAL_TESTCASES
RQM_TEST_ENVIRONMENT_NAME
RQM_SUITEEXECUTIONRECORD_NAME
RQM_SUITEEXECUTIONRECORD_WEBID
RQM_PROJECT_NAME
RQM_PROJECT_ALIAS
RQM_BUILDRECORD_NAME
RQM_BUILDRECORD_WEBID
RQM_BUILDDEFINITION_NAME
RQM_BUILDDEFINITION_WEBID
RQM_CONFIGURATION_NAME
RQM_CONFIGURATION_CPU
RQM_CONFIGURATION_ADAPTER
RQM_CONFIGURATION_APPLICATIONSERVER
RQM_CONFIGURATION_BROWSER
RQM_CONFIGURATION_DATABASE
RQM_CONFIGURATION_ITEMID
RQM_CONFIGURATION_MANAGEMENTAGENT
RQM_CONFIGURATION_OS
RQM_CREATEDBY_USERID
RQM_CREATEDBY_NAME
RQM_LABRESOURCE_NAME
RQM_LABRESOURCE_WEBID 
RQM_LAST_RESULT_FOR_MACHINE
RQM_TEST_CELL_NAME
RQM_TEST_CELL_MACHINE_COUNT
Note: The execution variables are provided to CLA scripts as environment variables with 'qm_' prefixed to the execution variable name. So to access the name of the test plan from a CLA script you would access the environment variable as 'qm_RQM_TESTPLAN_NAME'.

video icon Video

Jazz.net channel
Software Education channel

learn icon Courses

IoT Academy
Skills Gateway

ask icon Community

Jazz.net
Jazz.net forums
Jazz.net library

support icon Support

IBM Support Community
Deployment wiki