How to pass a variable in the background "Given" in a cucumber?

@TestHomeValidation
Feature:copy function test

  Background:
    Given I am running test in "VARIABLE" environment

Can it be used VARIABLEin the above description? I want to pass the VARIABLE value from the properties file.

+4
source share
3 answers

I am afraid that you will want to use an external data source to store variables to provide cucumber steps. That you could consider us using DataTable Scenario Outlines. In both cases, you can provide some local (intra-functional files) parameters. For instance:

Scenario: Scenario1 
  Given I have done "this" #this can be parsed by the glue code
  Then these can be used: #You can use DataTable type to parse multiple groups of variables
    | col1 | col2 | col3 |
    | x    | x1   | x2   |
    | y    | y1   | y2   |


Scenario Outline: <col1> test 
  Given I have done "<col2>"
  Then I can see "<col3>"
    | col1 | col2 | col3 |
    | par1 | par2 | par3 |
+1
source

As @eugene mentioned, this is not possible out of the box.

, .

, , , Gherkin, , .

,

+1

QAF gherkin client.

@TestHomeValidation
Feature:copy function test

  Background:
    Given I am running test in "${my.env}" environment

my.env . , , , QAF

+1

Source: https://habr.com/ru/post/1669007/


All Articles