SpecFormula AI
ISABackendSymbol System

VAR-System

Variable extraction, storage, and reference

VAR-System lets you pass dynamically generated values between test steps, such as auto-generated database IDs or tokens from API responses.

Four Syntax Forms

SyntaxNamePositionPurpose
>contextKeyContext KeyDataTable headerDefine variable name
<executionKeyExecution KeyDataTable dataSpecify field to extract
$variableVariable ReferenceAny value positionReference variable (preserves type)
${variable}String InterpolationWithin stringsEmbed variable (converts to string)

Extract Variables

Use > and < pairs to extract values from execution results:

When create user, call table:
  | >userId | >userToken | name  | email             |
  | <id     | <token     | Alice | alice@example.com |

After execution:

  • userId = value of id field from response
  • userToken = value of token field from response

Reference Variables

$variable (Type Preserving)

Then validate user exists, with:
  | id      | name  |
  | $userId | Alice |

$userId preserves the original type (Integer, String, etc.).

${variable} (Converts to String)

When batch query, call table:
  | ids                       |
  | ${user1.id},${user2.id}   |

${...} converts the value to a string, suitable for combining multiple variables.

$var vs ${var}

Aspect$variable${variable}
Use caseEntire value is the variableEmbedded within a string
TypePreserves original typeConverts to String
Multiple variablesNot supportedSupported
Example$userId → 12345"ID: ${userId}" → "ID: 12345"

Nested Paths

Supports dot notation and array indexing:

# Object nesting
| >orderId           |
| <order.details.id  |

# Array indexing
| >firstItem     |
| <items[0].name |

Pairing Rules

> and < must be paired within the same column:

Header:  | >contextKey | normalField | >anotherKey |
Data:    | <fieldName  | normalData  | <otherField |
         ↑ paired       ↑ not paired  ↑ paired

Duplicate Context Key: If multiple steps use the same >contextKey, Lint will issue a warning. At runtime, the later value overwrites the earlier one.

Quote Rules

  • When wrapped in quotes in DataTable, not parsed: "$var" is treated as plain string
  • In JSON DocString, variables must NOT be placed inside "", otherwise treated as plain string:
# ✅ Correct: symbol outside quotes
"""json
{ "userId": $userId }
"""

# ❌ Wrong: symbol wrapped in quotes, treated as plain string
"""json
{ "userId": "$userId" }
"""

Edge Behaviors

Null Handling

# Execution result is null → stored in ScenarioContext as null
| >agentId |
| <id      |  # id is null → agentId = null

# Variable not found → returns original string
| $undefinedVar |  # → string "$undefinedVar"

String Interpolation Edge Cases

# Unclosed bracket → preserves original text
| User ${name without closing |  # → "User ${name without closing"

# Variable doesn't exist → preserves original text
| User ${notFound} |  # → "User ${notFound}"

Reserved Words

now is a reserved word and cannot be used as a Context Key:

# ❌ Error
| >now |

Complete Example

Feature: Variable Passing

  Example: Create user then query
    # 1. Extract user ID
    When (No Actor) create user, call table:
      | >user1.id | name  | email             |
      | <userId   | Alice | alice@example.com |

    # 2. Use variable for query
    When (UID="$user1.id") get profile, call table:
      | |
    Then get profile(200) response, with table:
      | userId     | name  |
      | $user1.id  | Alice |

    # 3. String interpolation for batch query
    When (No Actor) create user, call table:
      | >user2.id | name | email           |
      | <userId   | Bob  | bob@example.com |
    When (No Actor) batch get users, call table:
      | Q:userIds                   |
      | ${user1.id},${user2.id}     |

On this page