Closed micheelengronne closed 4 years ago
You can use the --require
switch on the command-line to load step definitions from a Ruby file, which could be in a gem.
See, for example, the aruba
gem which bundles step definitions for testing command-line apps.
Thanks. Does it also work with features files ? Is there a possibility to have a meta features file that can load specific features scenarios from a sort of features library (bundled in a gem)?
Yes it's worth pointing out that a step file (Written in ruby), is just a series of commands which get loaded into your cucumber runtime and then converted. So if you had a gem for example which had a file which had 2 Given steps, then requiring that gem would allow you to use those common given steps.
Matt linked to some good examples. Here is a bit more detail.
Feature in cucumber-ruby https://github.com/cucumber/cucumber-ruby/blob/master/features/docs/exception_in_after_hook.feature#L26-L35
Consuming this step in aruba https://github.com/cucumber/aruba/blob/master/lib/aruba/cucumber/file.rb#L23-L25
^^^^ This step in aruba is used in 50+ scenarios in cucumber-ruby's acceptance tests. It allows us to dynamically create a step or feature quickly using a docstring.
Right for the steps but for features themselves ? In fact, this issue is related to https://github.com/cucumber/cucumber-ruby/issues/1076 and https://github.com/cucumber/cucumber-ruby/issues/821
Is the suites system implemented ?
Suites were not implemented, yet, no. They're still a great idea but we're waiting for them to work their way up the team's priorities.
Ok. This issue describes exactly what I am looking for https://github.com/cucumber/cucumber-ruby/issues/1109
Re-running features as described there I'd do in a ruby block, and run the features with whatever additional env vars / params are needed. Something like this pseudo-code
['var1', 'var2', 'var3'].each do |var|
bundle exec cucumber MYVAR=var
end
Hum... I think I will create a quick gem that download remote cucumber projects in tar.gz, unpack them, merge them and create a new cucumber project with all features together. A bit like Inspec
does with profile dependencies.
That way, I can easily call this tar.gz in my project to test.
Question :
features/*.feature
files ? In the same git as your project ?git clone
? Bundled in a gem and called with bundle?@micheelengronne do you mean in cucumber-ruby, if so they don't exist, they're created dynamically on the fly.
No, in general. When you created a features
folder with cucumber -init
, how do you distribute it ? Via git only ? Is there a norm to package it ?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.
This issue has been automatically closed because of inactivity. You can support the Cucumber core team on opencollective.
Summary
I would like to be able to package and reuse features and step definitions. I have multiple projects that have common functionnalities.
Is there a possibility to package groups of features and step definitions and create dependencies between these packages to avoid rewriting everything with every project ?
If we take a look at inspec profiles for instance, we can reuse previous definitions easily.
Expected Behavior
Given a new project When a similar functionnality than another project is tested Then download the features/step_definitions package from the other project and reuse it here
Current Behavior
AFAIK, there is no packaging and dependencies sytem in cucumber.
Context & Motivation
I want to greatly simplify maintaining features, step definitions and scenarios by spliting them in small structures and heavily reuse these structures.