Feature-file grammar
Structure
Feature: <business capability>
Scenario: <actor performs an observable outcome>
Given <starting state>
When <primary action>
And <supporting interaction>
Then <observable business result required by this testcase>
And <another required business assertion, when applicable>Use Given for starting state, When for actions, and Then only for
assertions that define whether the testcase passes.
Do not add a Then after every click, fill, search, set, select, upload,
download, navigation, or data-capture action. A scenario may contain several
actions followed by one meaningful Then — or no Then at all when its sole
purpose is to prepare data for another testcase.
When later work merely depends on the page being ready, use an operational wait instead of turning readiness into an assertion:
When I click the "New Account" button
And I wait until the "New Account" modal is ready
And I fill [$.testdata.account.name] in the "Account Name" text field
And I click the "Save" button
Then the Account record page should show [$.testdata.account.name]Variables
Given the created Account record page is open
When I save the current Account record URL as [$.output.record_url]| Variable | Holds |
|---|---|
[$.environment.<profile>.<field>] |
Environment configuration |
[$.testdata.<dataset>.<field>] |
Test inputs |
[$.output.<name>] |
Values created during execution |
[$.input.<name>] |
A value supplied to the current testcase, including an output from an earlier testcase in the same testsuite |
Cross-testcase values and files
A testcase publishes a reusable value or file with an output variable. A later testcase receives that output through its own input variable. Keep the feature syntax simple: the testsuite owns the output-to-input mapping.
Producer testcase:
When I click the "Download Customer Export" button
And I save this file as [$.output.customer_export]Consumer testcase:
When I read data as CSV from [$.input.customer_export]
Then the CSV should contain a row for customer [$.testdata.customer.id]The same handoff applies to other file types — use the reader that matches the file's meaning:
When I read data as JSON from [$.input.api_export]
When I read data as Excel from [$.input.financial_workbook]
When I read text from [$.input.application_log]
When I upload [$.input.signed_contract] using the "Upload Files" controlUse [$.output.<name>] only in the producing testcase and [$.input.<name>] in
the consuming one. Do not expose machine paths, copy file contents into feature
text, or make the consumer locate another testcase's working directory.
Runtime-unique test data
Use a runtime timestamp when a test creates data that must be unique across scenarios or repeated runs. The timestamp is appended to a fixed, user-provided value; it is not literal text and it does not replace the meaningful prefix.
These two forms express the same pattern:
When I fill "Automation Account {timestamp}" in the "Account Name" text field
When I fill "Automation Account " + current_timestamp in the "Account Name" text fieldIn both forms:
Automation Accountis the stable value supplied by the author.{timestamp}orcurrent_timestampis generated during execution.- The resolved value is a unique name such as
Automation Account 20260810154530123. - Generate a fresh value for each scenario or test case that creates independent data.
- Resolve the timestamp once for that logical value and reuse the exact result in later steps, assertions, lookups, and cleanup.
- Save the resolved value as an output when another scenario or workflow must reference it.
When I fill "Automation Account {timestamp}" in the "Account Name" text field
And I save the filled Account Name as [$.output.account_name]
And I click the "Save" button
Then the Account record page should show [$.output.account_name]NEVER
Do not write a bare timestamp without the customer-readable prefix, and do not generate a second timestamp when referring to a record that was already created with the first one.
Exact text
Quote exact visible strings:
When I click the "Save" button
Then I should see the heading "Account Details"Keep actions unquoted:
When I open the Accounts navigation itemHuman-only instructions
;skip; This record is created only in the authorized test environment.
;skip-start;
Business context for the author or reviewer.
These lines are not executed.
;skip-end;Do not place required actions or assertions inside skipped text.