Variables

Variables are names used to hold one or more values. Instead of repeating these values in multiple places in tests, the variable holds the results of a calculation, step execution, expression evaluation, or other value.

VIVIDUS provides the following syntax to access variable value:

${variableName}

Scopes

Variables can have one of the following scopes.

The scopes names are case-insensitive
Name Description

step

The scope is used within nested steps and the variables are invalidated after the nested steps are executed.

scenario

Variable declared with the scenario scope is available in the rest of the scenario after its declaration. The scenario-scoped variables are invalidated once the scenario is completed.

story

Variable declared with the story scope is available in the rest of the story after its declaration. The story-scoped variables declared inside given stories are available in the parent story. The variables are invalidated once the story is completed.

next_batches

Variable declared with the next_batches scope is available in the next batches. The next_batches-scoped variable is not available in batch it’s declared within.

global

Such variables are declared only via properties with bdd.variables.global. prefix and available throughout the entire execution. An attempt to create the globally scoped variables during test execution leads to an error.

Example 1. Declaring global variable login-endpoint
bdd.variables.global.login-endpoint=https://my-auth-server.com/api/login
Example 2. Using global variable login-endpoint
Given request body:
{
    "username":"user",
    "password":"pass"
}
When I set request headers:
|name        |value           |
|Content-Type|application/json|
When I issue a HTTP POST request for a resource with the URL '${login-endpoint}'
Then the response code is equal to '200'

If variable with the specified name is not found in any of VIVIDUS scopes, search for OS environment variable will be performed. If no OS environment variable is available, the variable placeholder will be kept as is: ${variableName}