Execution Variables
Last updated
Last updated
There are multiple scenarios to use Execution Variables:
Variables with data that is read from the system under test during test execution and are used later on. These are called runtime variables. For example: An order number that is generated during the test and needs to be verified on the invoice.
Variables in a test case which you want to be configurable and change between executions. For Example: run a test case with different login information or customer numbers
Variables that depend on a configuration or test environment. For example: the connection string to your database
Variables like passwords which you want to store encrypted and not write as plain text directly in a test case
In the Test Case Designer interactions that return a string, such as TextBox.GetText
or LabelWithValue.ReadValue
offer the possibility to save their output to a runtime variable. You can either select an existing variable from the dropdown or create a new variable with the + symbol.
Test executions which you start in the portal use the execution variables set on the software versions and on the test case. If a variable with the same name is set on both the software version and a test case, the value from the test case takes priority.
If you start an execution in Visual Studio directly the execution variables from the portal are loaded and updated with local values set through the execution variables dialog (assuming a connection to the portal exists).
Variables which are used by multiple test cases should be set on the software version, for example login information. Variables which are only used by one test case can be set on the test case directly.
In the Software and Environments Tab click the Edit Button to Edit your Software Version
Execution Variables can be set and edited on a Test Case with the following Button:
More information about about all the options of Portal Execution Variables can be found here.
Local Execution Variables are mainly used to set Variables which are secured/encrypted on the Portal and you do not have access to it. Or if you want to try other values than the ones set on Portal in a local execution.
If you start an execution in the TestResults.io Designer, the execution variables from the portal are loaded and updated with local values.
Secured (and therefore encrypted) variables from the Portal can not be loaded. So you need to set the values for these variables locally (e.g. password).
Local Variables are set on Solution Level, so they apply to all Test Cases.
Local Execution Variables are stored in the *.trio.user.json file in your solution folder, which is ignored by git. Therefore each user needs to set them separately.
Local Variables can be configured in the "Manage Execution Variables" dialog found in the Test Case Designer. Alternatively open the dialog from the solution context menu in the Solution Explorer.
To access a variable in code, use t.GetVariable()
.
For example to get the value of the variable with the key "model":
To use a variable as a parameterin the test case designer (e.g. select the variable value in a dropdown), first set the parameter to use variables with the icon and then select the desired variable from the dropdown list.