Ana
Ana

Reputation: 105

How to create a variable in env.rb or hook.rb and call in cucumber feature ?

Thank you in advance for help.

I am trying to create variable in env.rb

File_path =("#{File.dirname(__FILE__)}/../../features/TestData/Testdata.html")

and call File_path in the Cucumber feature directly.

for example
...
And I upload a file from path "<File_path>"
...

Is the is a better way of doing this ?

Upvotes: 1

Views: 802

Answers (1)

joelparkerhenderson
joelparkerhenderson

Reputation: 35453

Yes, there's a better way.

In your feature text, use meaningful names instead of file paths.

For example, any of these, depending on your goal:

And I upload a file of test data 

And I upload my web page

And I upload some previously saved information

Then put the file path in your step file.

In general, feature descriptions should be plain language, not source code, file paths, env vars, etc

Upvotes: 3

Related Questions