I've got three versions of a backend that I'm testing. I would like to run similar feature specifications against the three versions.
Initially, I thought I'd just organize everything in a directory structure, as such:
features/
v1/
something.feature
step_definitions/
something_steps.rb
v2/
something.feature
step_definitions/
something_steps.rb
v3/
something.feature
step_definitions/
something_steps.rb
However, cucumber seems to flatten everything, which means that I end up with ambiguous step definitions.
I then thought of the following structure:
features/
v1/
something.feature
v2/
something.feature
v3/
something.feature
step_definitions/
something_steps.rb
I'd define a variable in the feature file somewhere, indicating which version that one is for, and I'd have a bunch of "ifs" inside the steps file, to choose code paths depending on that version variable. However, I haven't found an obvious way of defining that variable in the feature file.
Is there any way I can organize things, or will I just have to create multiple "feature" roots, one per version, which would be an awful solution given that it would mean multiple invocations of cucumber?
v1/
features/
something.feature
step_definitions/
something_steps.rb
v2/
features/
something.feature
step_definitions/
something_steps.rb
v3/
features/
something.feature
step_definitions/
something_steps.rb
Why would multiple invocations of cucumber be a bad thing? Personally, that's how I'd do it, and run all three features from a Rakefile so I didn't have to do one after the other.
Also, if the conflicts are so large that you're rewriting the entire step definition for each version, maybe you should reconsider how you're wording them. Should you really describe it as doing the same thing if the code is so different?
If the changes are smaller, then I'd suggest looking at tags and hooks to achieve what you want.
So your feature might look like this:
And your step definition might look like this:
You can use this method even if the step definitions are very different, but I think it will be harder to manage.