Skip to main content

Random values

DrevOps\BehatSteps\Steps\Web\RandomTrait - Source, Example, Helpers

Replace random-value tokens in step arguments and table cells.

  • Resolve [?<name>:<type>[,<args>]] tokens to generated values.
  • Return 1 value per token for the whole scenario.

Built-in types are string, name, machine_name, int, email and uuid. The default is string with length 10, so [?title], [?title:string] and [?title:string,10] share 1 value.

Operates on Gherkin text alone: no Mink session and no backend, so the trait works in any suite.

Skip processing with tag: @behat-steps-skip:RandomTrait.

Options​

OptionTypeDefaultTagDescription
random.enabledbooleanTRUE@behat-steps-skip:RandomTraitIf TRUE, replaces [?name] and [?name:type] tokens in step arguments and table cells with random values, though not in multiline text. Tokens with the same name, type and arguments share 1 value for the whole scenario. If FALSE, tokens stay as written.