Variables and test data
Steps rarely need fixed values. This page explains how a step reads a {{variable}}, which steps produce one, where data sources and datasets come in, and how a pipeline runs the same test once per data row.
In short
On this page you can
- Insert a
{{variable}}instead of a fixed value in any step. - Store a value from the screen, an API or a query for later steps.
- Read test data from data sources, global parameters and datasets.
- Keep one value per environment with
NAME_DEV,NAME_TEST,NAME_PRP. - Run a test case once per dataset row in a pipeline.
How to use it
- Select the step and click the data picker icon next to a value.
- Pick a data source key, a global parameter or a dataset column.
- To pass a value on, give the producing step a key such as
orderNo. - Use
{{orderNo}}in a later step, save and dry run. - In the pipeline, set the execute count to iterate over the dataset.
How variables are written#
A variable is a name in double curly braces. You can use it as the whole value or inside text: Order {{orderNo}} was created. When the step runs, the variable is replaced by its value.
| Write | Means | Example |
|---|---|---|
{{name}} | A value from this run, or a stored global parameter | {{orderNo}} |
{{tc:name}} | A value this test case produced | {{tc:orderNo}} |
{{tc:1484.name}} | A value test case 1484 produced earlier in the same pipeline run | {{tc:1484.customerId}} |
{{ds:name}} | A key from a data source | {{ds:adminUser}} |
{{ds:name}}_column | One column of a data source record | {{ds:customers}}_email |
{{excel:name}}_column | One column of the current row of a dataset | {{excel:logins}}_password |
The prefixes make the source explicit and are what the data picker inserts. A name without a prefix still works, with limits (resolution order).
Insert a variable with the data picker#
Select the step
Click the step in the list. Its values open in Parameters List.
Open the picker
Click the picker icon next to the value (“Data Sources - Global Parameters - Datasets”). It is offered on typing, selection, navigation, hover, visibility, assertion and global parameter steps, on all mobile steps, and inside code, AI prompts, mail and Kafka messages.
Choose the source
The dialog Data Sources / Global Parameters / Datasets has three tabs:
- Data Sources List: keys from the project’s data sources (Connected Data Sources or All Data Sources).
- Global Parameters List: variables that steps of this and other test cases produce, with the test case they come from.
- Datasets: uploaded tables; pick a column.
Pick and save
Click the entry. The variable is inserted where your cursor was. Click Save.
The value shows the variable in colour, for example
{{ds:adminUser}}.
The picker warns you about order mistakes: “This parameter is produced by this step, so it has no value inside the step itself” and “This parameter belongs to a later step and may not have a value yet”.
Data sources and datasets are set up in the Data Source module of the main menu.
Steps that produce a variable#
A step produces a variable when you give its output a name (a key). Later steps read it as {{key}}.
| Step | Produces |
|---|---|
| Get (web), Get Text / Get Attribute / Store Variable (mobile, desktop) | The text or attribute of a control; on a Get step, transforms can clean it first |
| API | Values extracted from the response by JSON path or XPath, plus @status and @header:Name |
| Database | One variable per selected column |
| The OTP code or link found in the mail | |
| Network | Values extracted from a network call |
| Python, JS, AI step | The returned value, when the output is set to VALUE |
| Global parameter | The keys and values you type into it |
- Keys can only contain letters, digits and underscore (“Parameter key can only contain letters, digits and underscore”).
- Each key that creates a variable must be unique in the test case. Save stops with “Names that produce a global parameter must be unique within the test case. Conflicts: …” otherwise.
- Code and AI steps have three output modes: VALUE creates a variable; STATUS turns the returned value into pass or fail and creates no variable; NA produces nothing. An AI step that performs an action (AI Do) has no output.
- A value longer than 8,000 characters is not stored.
Kafka steps produce no variable: the step dialog has no output fields. The exact parameters of each producing step: step reference.
Where a variable gets its value#
{{tc:name}} 1. values produced earlier in this test case (shared run data)
2. values of earlier test cases in the pipeline
3. the project's stored global parameter of that name
{{ds:name}} the data source key {{excel:key}}_column → the dataset row
{{name}} 1. values produced earlier in this test case
2. only when the reference is the whole value: the stored global
parameter, i.e. this test case's variable, else a data source key or dataset
(inside longer text, step 1 only)
environment variant first: NAME_<ENV> if it exists, else NAME
not found → the text {{name}} is used literally
Example: step 3 is a Get with key orderNo and reads A-1029. Step 7 types {{orderNo}} into a search field: it types A-1029. If step 3 is deactivated, step 7 looks for a stored global parameter orderNo: values that steps produce are also stored, so it may type the order number from an earlier run. If there is none, it types the literal text {{orderNo}}.
An assertion treats a variable it cannot find as empty and logs “{{x}} not found, treated as empty”.
A wrong value is worse than no value
Because unresolved variables are typed as written and stale values can come from earlier runs, check the dry-run log of the step that should produce the value. For an API extraction, for example, the log shows the stored value as orderNo = A-1029.
Scope#
- Run data belongs to one test case run. A test case does not see another case’s values by plain name. Step-level details: How long a variable lives.
- In a pipeline, a later test case reads an earlier one’s value with
{{tc:<caseId>.name}}. - A template runs inside its caller: it reads the caller’s variables and the caller reads what it produces. The template step’s Reads and Produces list them.
One value per environment#
A user name or a customer number often differs between DEV, TEST and PRP. Keep it as separate data source keys or datasets named NAME_DEV, NAME_TEST and NAME_PRP, and use only {{NAME}} in steps. A run on TEST uses NAME_TEST if it exists, otherwise NAME. The suffix must be upper case and exact. A name you write with a suffix is used as written.
adminUser_DEV dev.admin@example.com
adminUser_TEST test.admin@example.com
adminUser fallback.admin@example.com
Step value: {{ds:adminUser}} → on TEST: test.admin@example.comRun a test case once per data row#
A test case that reads {{excel:logins}}_user and {{excel:logins}}_password can run once for every row of the logins dataset. You set this in the pipeline, as the test case’s execute count, in Schedule:
| Execute count | Runs |
|---|---|
{{excel:logins}}_# | Every row, in order |
{{excel:logins}}_#5 | The first 5 rows |
{{excel:logins}}_? | Every row, in random order |
{{excel:logins}}_?5 | 5 random rows |
Each row is a full run of the test case with a fresh browser. If you ask for more runs than there are rows, the rows repeat from the start.
Dry run uses the first row
A dry run does not iterate. It uses the first row of each dataset and the values stored in the steps; pipeline parameter overrides do not apply.
Test case values and pipeline values#
Each pipeline keeps its own copy of the parameters of the test cases it runs, so the same test case can run with different values in different pipelines. When you change a test case’s parameters, Save offers to sync them into its pipelines; see Test Case Parameters Changed.
Secrets and personal data#
- Values typed into a step are stored in the test case and visible to everyone in the project. Put passwords and tokens in a data source and reference them with
{{ds:…}}, so they live in one place. - Values typed into fields whose name looks like password, secret, token or PIN are shown as
••••••in run logs. - The runner receives the values it needs to run the test, wherever it runs: the server or your agent.
- Use test users and test data. Never put real customer data into datasets.
If something goes wrong#
- The test typed
{{name}}literally - A step used a value from an earlier run
- “Duplicate keys found in step:” or “Names that produce a global parameter must be unique…”
- “This key is already registered as a global parameter…”
- “Parameter key can only contain letters, digits and underscore”
- The dry run used only one data row
Didn’t find your answer?Write to support with your project name and what you see on screen.
info@smartestqa.ai