I'd like to execute Cucumber features from within Ruby code.
Typically the cucumber
binary installed with the gem is executed on the command line with one or more features specified.
However, I'd like to define logic that creates a dynamic feature execution flow. In other words, the program can work out which features should be executed.
Is it possible to instantiate Cucumber with specified feature files from Ruby code as opposed to the command line?
I discovered how from the mailing list and some API reading.
If you want all features within your gem's
features/
directory to be executed, pass an empty array toMain.new
instead.To convert this example command, with features and options specified:
into Ruby code, it boils down to passing Cucumber an
args
array:Tested using Ruby 2.0.0p598 and Cucumber 1.3.17