Skip to content

Variables and Local Values

Testform implements a variable (variable:) and local values (locals:) resolution engine inspired by Terraform, but adapted to the native readability of YAML.

No .tfvars or JSON files required: everything is declared and resolved in YAML.


Variables represent configurable input parameters declared with metadata:

variable:
app_url:
type: string
description: "Base URL for the test environment"
default: "https://www.saucedemo.com"
environment:
type: string
description: "Target environment (dev, staging, prod)"
default: "dev"
default_timeout:
type: number
default: 5000

Referenced in .feature files via: ${var.variable_name}

The locals: Block (Local and Computed Values)

Section titled “The locals: Block (Local and Computed Values)”

Locals represent derived constants or computed expressions to prevent code duplication:

locals:
base_url: "${var.app_url}"
login_url: "${local.base_url}"
api_health: "${local.base_url}/health"
tag_env: "@env-${var.environment}"

Referenced via: ${local.local_name}

Testform resolves transitive dependencies (locals referencing other locals or variables) through multiple evaluation passes.


When the same variable is defined across multiple files or commands, Testform applies strict precedence (from lowest to highest):

▲ HIGHEST PRIORITY
│ [Level 5] CLI Flags: -var "key=value"
│ [Level 4] CLI Var Files: -var-file="staging.yml"
│ [Level 2] Domain Folders: auth/auth.yml, inventory/inventory.yml, etc.
│ [Level 1] Terraform Standard: variables.yml, locals.yml
│ [Level 0] Base Manifest: main.yml (global defaults)
▼ LOWEST PRIORITY

3. Usage in Gherkin Feature Files (.case.feature)

Section titled “3. Usage in Gherkin Feature Files (.case.feature)”

Variables and locals are interpolated seamlessly in both tags and steps:

@testcase
Feature: User Authentication in SauceDemo
@tc-1 @auth @smoke ${local.tag_env}
Scenario: Successful login with standard user
Given the user navigates to "${local.login_url}"
When entering username "standard_user"
And entering password "secret_sauce"
And clicking the "Login" button
Then the system redirects to "${var.app_url}/inventory.html"