Default language.

Variable


The Variable element is used for defining data in one place and later refer to the data by using a Data Reference element. Hence, test data can be defined in a Variable in the beginning of the test scenario, which makes it easier to understand and to change.

Add Variable to the Test Scenario by dragging it from the tool palette. This opens the Insert a new Variable element popup. Here are the fields available when setting up this element:

  • ID - is a unique name used to refer to output from this element to other elements in this Test Scenario. Reference to this ID by using the format ${myid}.
  • Description - an optional description of the Test Element.
  • Simple tab - attribute contains a simple String value.
  • List tab - attribute contains a list of String values.
  • Structure tab - attribute contains a complex data structure.
  • From File tab - attribute can refer to data in an XML file, a property file or a Microsoft Excel spreadsheet. This is used to reference a file containing data to load. The path is relative to the test scenario file directory.
    • It can have the data defined as child elements. A variable can easily be added by drag and drop of an xml or property file into the test scenario editor.
    • To reference a Microsoft Excel spreadsheet, data must be defined from row 2. First column contains a label, while the next columns contain the values for data items. It is supported to use formulas in cells. Total Test will evaluate the formulas and calculate the resulting cell values.
    • Sample of Spreadsheet_data.xls:
      image2021-8-16_23-8-10.png
  • OK / Cancel - click on OK to save your element.

Reassign a Variable

Reassigning a variable with a new value can be useful if you want to iterate through data in order to calculate a number and assign it to a variable. The illustration below shows a test scenario on the left where the variable a is set to 5, then reassigned to a+1. On the right side, the result shows that a is now 6.0.

Test Scenario Elements

image2021-4-2_16-3-52.png

Use Expression in a Variable

To add an Expression element to a Variable, right-click the Variable element and from the context menu, select Insert into > Expression. The variable will contain the value of the evaluated expression and can then be used for variable substitution. This can be used, for example, to calculate a date two weeks from today.

image2021-4-2_16-5-44.png

Use variable substitution for the file path in a variable

The file path for a Variable element points to a property, Excel or XML file to import data from. The file path value supports variable substitution such that the file to read from can be controlled by a variable. This can be useful when designing a Test Scenario that can be used inside other test scenarios.

image2021-4-2_16-6-52.png

Use variable substitution for the value in a select or verify statement in the Verify Dataset element

The Verify Dataset element has a Verify mode where a user can specify selection and verify expressions on specific records in a data set. The value of the record selection and verify expressions now supports variable substitution which increases the flexibility of the Verify Dataset element. The illustration below shows the XML syntax since the UI dialog box would require several screen shots.

image2021-4-2_16-7-56.png

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*