Create variables

As you know variables usually are defined at the beginning of the test case (testcase-variables). It might also be helpful to reset existing variables as well as to define new variables during the test. The action is able to declare new variables or overwrite existing ones.


<testcase name="createVariablesTest">
        <variable name="myVariable" value="12345"/>
        <variable name="id" value="54321"/>
            <message>Current variable value: ${myVariable}</message>

            <variable name="myVariable" value="${id}"/>
            <variable name="newVariable" value="'this is a test'"/>

            <message>Current variable value: ${myVariable} </message>

              New variable 'newVariable' has the value: ${newVariable}

Java DSL designer and runner

public void createVariableTest() {
    variable("myVariable", "12345");
    variable("id", "54321");

    echo("Current variable value: ${myVariable}");

    createVariable("myVariable", "${id}");
    createVariable("newVariable", "this is a test");

    echo("Current variable value: ${myVariable}");

    echo("New variable 'newVariable' has the value: ${newVariable}");

Note Please note the difference between the variable() method and the createVariable() method. The first initializes the test case with the test variables. So all variables defined with this method are valid from the very beginning of the test. In contrary to that the createVariable() is executed within the test action chain. The newly created variables are then valid for the rest of the test. Trailing actions can reference the variables as usual with the variable expression.