1

I have the following scenario

Given I'm from registered on "Brazil" website
When I login
Then i should receive a ok stats.

The Brazil website is almost the same as the US website. it only changes the url, and text language, but the system is all the same.

arguments works strictly for each country.

I don't want to copy paste this scenario for all countries and I'm wondering if i can have feature/support file so i can replace the "brazil" argument for something more dynamic.

Maybe run like cucumber all tests --arguments "brazil"

Cœur
  • 37,241
  • 25
  • 195
  • 267
Leonardo Galani
  • 184
  • 5
  • 22

2 Answers2

3
cucumber COUNTRY=my_country

then you can get value with

ENV['COUNTRY']

Then you can write

Given I'm from registered on what ever country website
When I login
Then i should receive a ok stats.

in the step definition

  @country = ENV['COUNTRY']

and use them like you want

see here

Passing variables on the command line to a Cucumber test

pass special values to Cucumber

The first link show interesting way using cucumber profiles.

Community
  • 1
  • 1
Montells
  • 6,389
  • 4
  • 48
  • 53
0

I would suggest changing you Scenario to:

Given I am on the "Brazil" website
When I register
When I login
Then i should receive a ok status

Then you can create a case statement (if in Ruby) in the step definition for each location website. and the other 3 rules can remain global to all the sites.

Or, alternatively you can just use the full URL for the first url and keep the step definition rule simple.

Given I am on the "http://www.brazil_url.com" website
Given I am on the "http://www.usa_url.com" website
Carldmitch
  • 409
  • 2
  • 5