Open tomhicks-bsf opened 10 years ago
I've just had a look through the Cucumber code and there doesn't seem to be a way of removing a step definition, which seems a bit daft, but there is a way of instantiating "A Whole New World", which could be useful and might also please Aladdin fans.
OK so more reading around this reveals that this is considered an anti-pattern: https://github.com/cucumber/cucumber/wiki/Feature-Coupled-Step-Definitions-%28Antipattern%29
I struggle to agree with that, however. I think this is to assume that developers don't know how to decide on a code-sharing strategy for themselves. This is the same argument posted here.
Given that pioneer gives us the opportunity to abstract over Cucumber, how does anyone feel about promoting this concept here?
I think that the way step definitions are shared across features is short-sighted and can be improved. I see that being able to shove step definitions anywhere into the the /steps folder makes things easy to get started with, but it quickly gets unmanageable and I can't figure a way around it.
My problem is that step RegExs will collide very quickly when you get a non-trivial number of tests. For example, "I save the form" might be used in several different places in the same app, with slightly different ways of saving a form.
Instead of having what is essentially one global namespace for all whens and thens, they should be contextual, but with the ability to share steps if necessary. That is, private by default, shared when necessary.
So, I think that when running feature1.feature, it should load the steps in feature1.js (from a designated directory) and no others. If you want to share steps, you do it something like the following:
Thoughts?