3

I am using cucmber+selenium. Is there a way i can pass options to @Cucumber.Options dynamically. Something like-

features="src/YahooSearch.feature" // i want to take this feature file names from excel & put here...

Deepak
  • 336
  • 1
  • 3
  • 10
  • I'm afraid that you cannot do this in Java because annotation and its parameters are resolved at compile time. so you can't just dynamically change it – Vicky Jul 11 '15 at 21:31

3 Answers3

0

One way of setting it is through the System.setProperties() method. Say, if my resources/features folder has all the necessary features, I can simply instruct Cucumber to scan for all the features in the folder like,

String features = "/src/main/resources/features";
System.setProperty("cucumber.options", features);

Also, you can instantiate your RuntimeOptions dynamically like

new RuntimeOptions(features);
Prasanna
  • 2,593
  • 7
  • 39
  • 53
0

You could code something simple by passing command line parameters and retrieving them using ENV['xxx'].

Please see this post

Community
  • 1
  • 1
Almund
  • 5,695
  • 3
  • 31
  • 35
0

Instead of using Junit, use TestNG to invoke feature files. The flow goes like, Read from Excel and with the data generate testng XML suite dynamically to invoke each feature file. Please find the reference below,

https://github.com/sahajamit/cucumber-jvm-testng-integration

ABS
  • 61
  • 2
  • 10